marcmarder161 3 Report post Posted December 5, 2016 (edited) First, I apologize for my english, but lets continue... The script can be used for every server available out there. This is my restart script and I thought I better share it, to save you guys some time. No Crontab needed here... The script runs in a loop continuous checking whether the server is started or not. You can see the output when you type screen -r or screen -r YOURSCREENNAME When you don't know what the application screen is, don't make a server T H I N G S T O D O: make sure that your restart script is set to shutdown the server after *your restart time* exile_server_config > restart OR infistart config > restart the server have to shutdown so the script knows that it should re-start the server chmod +x restart.sh (basicly make it executable) VVVVVVVVVVVV better you make a second script that executes this script like this VVVVVVVVVVVV Dont forget to make it execuable screen -dmS armaserver ./restart.sh make sure you modify your server parameters in the script make sure you modify all strings @ the start of the script do not remove #bin/bash !!!!!!!!!!!! If you want help, provide all information you can get i am open for suggestions or edits Read all instruction in the file remove the curl "" part or install the app Simplepush (android) to get notifiyed when your server doing something Any suggestions for another scripts? Spoiler #!/bin/bash ############################################################# #You can spread / share the script, but give credits 2 @Marder ############################################################# PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/steam/arma3/restart.sh export DISPLAY=:0.0 set +x backupdir="/home/steam/backups" executedir="/home/steam/arma3" logdir="logs" armalog1="armac.log" armalog2="armar.log" interval=1m a3startparamfile="arma3server_startup_parameters.cfg" toexecute="arma3server" ################################################################### RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' CYAN='\033[0;36m' NC='\033[0m' printf "${GREEN}Variables set${NC}\n" ##################################################################### # #If you have Problems, you can find me on my Teamspeak: NotOnlyOne.de #Please provide all information you can get, if i should help you! #And consider too to join my Exile Server! NotOnlyOne Exile ################################################################### #ONLY IF YOU KNOW WHAT YOU ARE DOING, YOU CAN MODIFY THE ABOVE #EDIT THE "/home/steam/arma3/restart.sh" PART TO MATCH YOUR DIRECTORY ################################################################### #Remove curl 'https://api.simplepush.io/send/YOURID/Info/Server_started' > /dev/null 2>&1 #when you dont want to get notified, on your Phone. ################################################################### #Make sure all the files are owned by your current user! #And your are not running the root user #If some mods dont startup, check the Lower/High Case in the Mod/addons Directory ################################################################### backup(){ printf "${CYAN}Doing Backup${NC}\n" tar -cvpzf $backupdir/arma3backup$time.tar.gz ../arma3 > /dev/null 2>&1 curl 'https://api.simplepush.io/send/YOURID/Info/Backup_done' > /dev/null 2>&1 printf "${GREEN}Backup done${NC}\n" return $TRUE } notneeded(){ echo "" > /dev/null 2>&1 return $TRUE } cleanup(){ printf "${CYAN}Cleanup...${NC}\n" find . -wholename "*.log" -size +1000k -delete find $backupdir -mindepth 1 -mtime +7 -delete printf "${GREEN}Cleanup done${NC}\n" return $TRUE } printf "${CYAN}Setting Parameters...${NC}\n" rm $a3startparamfile ############################################You Can Modify This, To Match Your Server Start Parameters############################################################### echo '-config=config.cfg' >> $a3startparamfile #add a line like this one echo '-mod=@exile;@extended_base_mod;@cba_a3;@cup_weapons;@cup_units;@cup_vehicles;' >> $a3startparamfile #to add more parameters echo '-servermod=@exileserver;@advance_rappelling;@advance_urban_rappelling;@enigma;@cba_a3;@AdvancedTowing;' >> $a3startparamfile # echo '-autoinit' >> $a3startparamfile # echo '-loadMissionToMemory' >> $a3startparamfile # echo '-enableHT' >> $a3startparamfile # ####################################################################################################################################################################### printf "${GREEN}Parameters set${NC}\n" while : #again, touch this part only do #if you know what you do! time=`date +%b-%d-%y` #touch it, fuck it hour=$(date +%H) if [ "$EUID" -ne 0 ] then if pgrep $toexecute > /dev/null 2>&1 then notneeded else echo "===========$(date)===========" if (( 5 <= 10#$hour && 10#$hour < 9 )) then if [ -f $backupdir/arma3backup$time.tar.gz ]; then notneeded else printf "${GREEN}Doing a Backup${NC}\n" backup fi cleanup fi ./$toexecute -par=$a3startparamfile > $logdir/$armalog1 2> $logdir/$armalog2 & if pgrep $toexecute > /dev/null 2>&1 then curl 'https://api.simplepush.io/send/YOURID/Infi/Server_started' > /dev/null 2>&1 printf "${GREEN}Server started${NC}\n" else curl 'https://api.simplepush.io/send/YOURID/ERROR/Server_could_not_start' > /dev/null 2>&1 printf "${RED}SERVER COULD NOT START${NC}\n" fi echo ================================================= fi else printf "${RED}I WILL NOT RUN AS ROOT${NC}\n" echo "You really want to break me right?" exit 1 fi sleep $interval done ####################################################################################################################################################################### Solves for problems that could occour: Make sure all files / directorys are owned by the user DO NOT USE ROOT ffs All paths are right The current user have enough rights Edited December 5, 2016 by marcmarder161 2 Share this post Link to post Share on other sites
BetterDeadThanZed 1006 Report post Posted December 5, 2016 Moved from the XM8 App forum to the Linux forum. 1 Share this post Link to post Share on other sites
footman1000 1 Report post Posted November 19, 2017 (edited) Hi and big thx, this helped me alot! But, a little things changed hier at line 57 to 67 Spoiler printf "${CYAN}Setting Parameters...${NC}\n" rm $a3startparamfile ############################################You Can Modify This, To Match Your Server Start Parameters############################################################### echo '-cfg=@ExileServer/basic.cfg' >> $a3startparamfile # echo '-config=@ExileServer/config.cfg' >> $a3startparamfile #add a line like this one echo '-mod=@Exile;@Extended_Base_Mod;' >> $a3startparamfile #to add more parameters echo '-servermod=@ExileServer;@A3XAI;' >> $a3startparamfile # echo '-autoinit' >> $a3startparamfile # echo '-loadMissionToMemory' >> $a3startparamfile # echo '-enableHT' >> $a3startparamfile # ####################################################################################################################################################################### Thats my "startparamfile" lines. Edited November 19, 2017 by footman1000 1 Share this post Link to post Share on other sites