1. I have searched the forums for a way to automate the above mentioned and everyone said it cant be done at this time. Its possible I am not the first or I did bad research and didn't see that this was already being done. But, a friend and I have spent the last few days working on a powershell script to automate the updating of plugins for our server. I was interested in sharing this with the forums, but I currently intend to run it daily and it actively downloads the files each time as I have not gone into trying to compare versions. I didn't want to release our code if it going to cause harm to your servers or ability to host services if a bunch of people start using this and downloading all their plugins daily or possibly even more often.

    I would like to know if the mods/owners feel okay with me releasing the code we found, burrowed, and tweaked to boot our server. This includes running Steamcmd for their updates, downloading Oxide itself, downloading all the plugins, and finally starting the server. If you would like to see the code first I will happily provide it to you first.
    -phatboydw
     
  2. Wulf

    Wulf Community Admin

    There are actually quite a few bash and batch scripts floating around that handle everything aside from plugins.
     
  3. I do have one that work for plugins, I just wanted to make sure I wasn't going to cause an undo harm. So if you guys are okay with that i will attach it to this thread.
     
  4. i would like to see it. or you can pm me the info
     
  5. The below is all the scripts I have to start up the server from the ground up. If you have any questions let me know.

    This is my primary RustServerUpdate.bat
    Code:
    SETLOCAL EnableExtensions
    set EXE=RustDedicated.exe
    set /a COUNT=0
    :WHILELOOP
      FOR /F %%x IN ('tasklist /NH /FI "IMAGENAME eq %EXE%"') DO IF %%x == %EXE% goto FOUND
        D:\ArkServer\SteamCMD\steamcmd +runscript RustServerUpdate.txt
        goto SUCCESS
      :FOUND
        taskkill /IM RustDedicated.exe /t /f
        timeout 10
        set /a COUNT+=1
        if %COUNT% lss 60 goto WHILELOOP
        goto FAIL
    :FAIL
      echo %date% %time% Rust Server Failed to Update >> RustServerlog.txt
      goto STOP
    :SUCCESS
      echo %date% %time% Rust Server Updated Successfully >> RustServerlog.txt
      goto OXIDE
    :OXIDE
      ::Update Base Oxide Files
        bitsadmin /transfer downloadOxide /download /priority normal https://github.com/OxideMod/Snapshots/blob/master/Oxide-Rust.zip?raw=true D:\RustServer\serveroxide\Oxide-Rust.zip
        cd /d D:\RustServer\serveroxide
        "D:\Program Files\WinRAR\WinRar.exe" x Oxide-Rust.zip
        :CHECKOXIDE
          if exist Oxide-Rust.zip goto DELOXIDE
          goto COPYOXIDE
        :DELOXIDE
          del Oxide-Rust.zip
          goto CHECKOXIDE
        :COPYOXIDE
        xcopy D:\RustServer\serveroxide D:\RustServer /e /y
        timeout 2
        rd /q /s .
      ::Update Oxide Plugins
        powershell.exe D:\RustServer\rustpluginfetch.ps1
      goto FIN
    :FIN
      D:\RustServer\ServerStart.bat
    :STOP
    Simple Steam Command Script
    Code:
    login anonymous
    force_install_dir D:\RustServer
    app_update 258550
    quit
    The Plugins Update Powershell Script
    Code:
    $helper=new-object -com WScript.Shell
    $root='http://oxidemod.org/plugins/'
    $pluginlist = 'D:\RustServer\server\Server1\oxide\plugins\plugins.txt'
    $fetch = gc $pluginlistFunction Download($Tvar){
        $ie=new-object -com internetexplorer.application
        $url='http://oxidemod.org/' + (invoke-WebRequest -uri $root$Tvar | select -expand links | select -expand href | sls -simplematch 'version=')
        $ie.navigate($url)
        Start-Sleep -Seconds 2
        $helper.AppActivate('View Downloads - Internet Explorer', $true)
        start-sleep  2
        $helper.SendKeys('{ENTER}')
        Start-Sleep -Seconds 2
        $helper.SendKeys('{ESC}')
        rv url
        rv Tvar
    }for ($i=0; $i -lt $fetch.Length; $i++) {
      Download($fetch[$i])
    }rv fetch
    rv pluginlist
    rv root
    rv helper
    rv iMove-Item D:\Users\<name>\Downloads\RemoverTool.cs D:\RustServer\server\Server1\oxide\plugins\RemoverTool.cs -Force
    Move-Item D:\Users\<name>\Downloads\DeathNotes.cs D:\RustServer\server\Server1\oxide\plugins\DeathNotes.cs -Force
    Move-Item D:\Users\<name>\Downloads\playerlocation.lua D:\RustServer\server\Server1\oxide\plugins\playerlocation.lua -Force
    Move-Item D:\Users\<name>\Downloads\m-Time.lua D:\RustServer\server\Server1\oxide\plugins\m-Time.lua -Force
    Move-Item D:\Users\<name>\Downloads\admin-door-unlocker.lua D:\RustServer\server\Server1\oxide\plugins\admin-door-unlocker.lua -Force
    Move-Item D:\Users\<name>\Downloads\VACKicker.cs D:\RustServer\server\Server1\oxide\plugins\VACKicker.cs -Force
    Move-Item D:\Users\<name>\Downloads\AdminProtection.cs D:\RustServer\server\Server1\oxide\plugins\AdminProtection.cs -Force
    Move-Item D:\Users\<name>\Downloads\AutoDoorCloser.cs D:\RustServer\server\Server1\oxide\plugins\AutoDoorCloser.cs -Force
    Move-Item D:\Users\<name>\Downloads\NoDecay.cs D:\RustServer\server\Server1\oxide\plugins\NoDecay.cs -Force
    Move-Item D:\Users\<name>\Downloads\WeatherController.cs D:\RustServer\server\Server1\oxide\plugins\WeatherController.cs -Force
    Move-Item D:\Users\<name>\Downloads\PlayersOnline.cs D:\RustServer\server\Server1\oxide\plugins\PlayersOnline.cs -Force
    Move-Item D:\Users\<name>\Downloads\Crosshair.cs D:\RustServer\server\Server1\oxide\plugins\Crosshair.cs -Force
    Move-Item D:\Users\<name>\Downloads\StackSizeController.cs D:\RustServer\server\Server1\oxide\plugins\StackSizeController.cs -Force
    Move-Item D:\Users\<name>\Downloads\CraftingController.cs D:\RustServer\server\Server1\oxide\plugins\CraftingController.cs -Force
    Move-Item D:\Users\<name>\Downloads\GatherManager.cs D:\RustServer\server\Server1\oxide\plugins\GatherManager.cs -Force
    Move-Item D:\Users\<name>\Downloads\LimitedLadders.cs D:\RustServer\server\Server1\oxide\plugins\LimitedLadders.cs -Force
    Move-Item D:\Users\<name>\Downloads\NightLantern.cs D:\RustServer\server\Server1\oxide\plugins\NightLantern.cs -Force
    Move-Item D:\Users\<name>\Downloads\m-Teleportation.lua D:\RustServer\server\Server1\oxide\plugins\m-Teleportation.lua -Force
    Move-Item D:\Users\<name>\Downloads\Kits.cs D:\RustServer\server\Server1\oxide\plugins\Kits.cs -Force
    Move-Item D:\Users\<name>\Downloads\Cornucopia.cs D:\RustServer\server\Server1\oxide\plugins\Cornucopia.cs -Force
    The plugins text script for the download loop
    Code:
    death-notes.819
    player-location.663
    day-night-system.671
    admin-door-unlocker.756
    vac-kicker.985
    admin-protection.869
    autodoorcloser.800
    weather-controller.1180
    players-online.1218
    crosshair.1236
    stack-size-controller.1185
    crafting-controller.695
    gather-manager.675
    limited-ladders.1051
    nightlantern.1182
    teleportation-system.660
    r-remover-tool.651
    kits.668
    cornucopia.1264
    nodecay.1160
     
  6. seems to be legit, and working, but i was hoping for a script that would update plugins on the go, while server is running. When plugin is updated = download and install..
    But thanks for your share.
     
  7. In my little experience it doesn't seem plugins take effect until the server is rebooted. So you would have to reboot your server each time you receive noticed of an update. By doing this daily it will keep your server up to date automatically instead of the current manual downloading of each plugin each time.
     
  8. Isn't that just a simple oxide.reload PLUGIN
     
  9. also if a plugin file changes at runtime oxide will automatically reload that plugin for you
     
  10. Wulf

    Wulf Community Admin

    Plugins are automatically reloaded if changed at all.
     
  11. From what I have seen, the plugins won't activate without a reboot. So I am not sure why my results of have been different. If that's the case then all you need to figure out on my code is how to read your email for the notifications and see about doing select cases in PS if that's possible. For each trigger result have it run the correlating plugin download. I personally am okay with keeping my system updated daily, I run this particular servers updates at about 4:15AM every morning. I hope this script is able to help other people.
     
  12. Wulf

    Wulf Community Admin

    If you are updating the a file that is the exact same as the previous, nothing will happen, which is likely your case. The file has to physically have changed to be reloaded. Plugins are also automatically loaded if they are not already loaded once you've placed them in the oxide/plugins folder.
     
  13. Cleaned up The Plugins Update Powershell Script by adding the moving of the file into the for loop and creating a second text file for the filenames. Figured its easier to go this route then add the entire command everytime i want to add a new plugin. Enjoy.
    Code:
    $helper=new-object -com WScript.Shell
    $root='http://oxidemod.org/plugins/'
    $fetch = gc 'D:\RustServer\server\Server1\oxide\plugins\plugins.txt'
    $felch = gc 'D:\RustServer\server\Server1\oxide\plugins\filepath.txt'Function Download($Tvar){
        $ie=new-object -com internetexplorer.application
        $url='http://oxidemod.org/' + (invoke-WebRequest -uri $root$Tvar | select -expand links | select -expand href | sls -simplematch 'version=')
        $ie.navigate($url)
        Start-Sleep -Seconds 1
        $helper.AppActivate('View Downloads - Internet Explorer', $true)
        Start-Sleep -Seconds 2
        $helper.SendKeys('{ENTER}')
        Start-Sleep -Seconds 1
        $helper.SendKeys('{ESC}')
        rv url
        rv Tvar
    }for ($i=0; $i -lt $fetch.Length; $i++) {
      Download($fetch[$i])
      Move-Item D:\Users\[name]\Downloads\$($felch[$i]) D:\RustServer\server\Server1\oxide\plugins\$($felch[$i]) -Force
    }rv fetch
    rv felch
    rv root
    rv helper
    rv i
    filepath.txt
    Code:
    DeathNotes.cs
    playerlocation.lua
    m-Time.lua
    admin-door-unlocker.lua
    VACKicker.cs
    AdminProtection.cs
    AutoDoorCloser.cs
    WeatherController.cs
    PlayersOnline.cs
    Crosshair.cs
    StackSizeController.cs
    CraftingController.cs
    GatherManager.cs
    LimitedLadders.cs
    NightLantern.cs
    m-Teleportation.lua
    RemoverTool.cs
    Kits.cs
    Cornucopia.cs
    NoDecay.cs
    InfoPanel.cs
    DayVote.lua
    Clans.cs
    HeliControl.cs
    QuickSort.cs
    QuickSmelt.cs
    RainOfFire.cs
    BuildingGrades.cs
     
  14. Code:
      Move-Item C:\Users\[name]\Downloads\$($felch[$i]) C:\Rust_Server\server\st_server\oxide\plugins\$($felch[$i]) -Force
    
    Code:
    >> Running (rustpluginfetch.ps1) Script Selection...
    >> Platform: V5 64Bit (STA) (Elevated)
    ERROR: Cannot index into a null array.
    rustpluginfetch.ps1 (22, 41): ERROR: At Line: 22 char: 41
    ERROR: +   Move-Item C:\Users\[name]\Downloads\$($felch[$i]) C:\Rust_Server\se ...
    ERROR: +                                         ~~~~~~~~~~
    ERROR:     + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    ERROR:     + FullyQualifiedErrorId : NullArray
    ERROR:
    ERROR: Cannot index into a null array.
    rustpluginfetch.ps1 (22, 101): ERROR: At Line: 22 char: 101
    ERROR: + ... ]) C:\Rust_Server\server\st_server\oxide\plugins\$($felch[$i]) -Force
    ERROR: +                                                        ~~~~~~~~~~
    ERROR:     + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    ERROR:     + FullyQualifiedErrorId : NullArray
    ERROR:>> Execution time: 00:00:01
    >> Script Ended
    
     
    Last edited by a moderator: Dec 18, 2015