Kierra

Untitled

Jun 9th, 2013
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.29 KB | None | 0 0
  1. #!/bin/bash
  2. #/test/rush1/start.bash
  3.  
  4. #Variables
  5.  
  6. SCREEN='rush1'
  7. SERVICE='/home/test/rush1/rush1.jar'    #Emplacement du .jar
  8. USER='test'                             #Utilisateur
  9. PATH='/home/test/rush1/'                #Emplacement du répertoire contenant le .jar
  10. WORLD='/world/'                         #Map à lancer
  11. ORIGINWORLD:'/rush/'                    #Map d'origine
  12. MAXHEAP=512                             #RAM allouée max
  13. MINHEAP=258                             #Ram allouée min
  14. HISTORY=1024                   
  15. CPU_COUNT=1                             #Nombre de coeurs alloués
  16. INVOCATION="java -Xmx${MAXHEAP}M -Xms${MINHEAP}M -XX:+UseConcMarkSweepGC \
  17. -XX:+CMSIncrementalPacing -XX:ParallelGCThreads=$CPU_COUNT -XX:+AggressiveOpts \
  18. -jar $SERVICE"
  19.  
  20. #Fonctions
  21.  
  22. ME=`whoami`
  23. as_user() {
  24.   if [ $ME == $USERNAME ] ; then
  25.     bash -c "$1"
  26.   else
  27.     su - $USERNAME -c "$1"
  28.   fi
  29. }  
  30.  
  31. rmworld() {
  32. cd $PATH
  33. rm -r $WORLD
  34. }
  35.  
  36. cpworld(){
  37. cd $PATH
  38. cp -r $ORIGINWORLD $WORLD
  39. }
  40.  
  41. mc_start() {
  42.   if  pgrep -u $USERNAME -f $SERVICE > /dev/null
  43.   then
  44.     echo "$SERVICE est déjà lancé !"
  45.   else
  46.     echo "Lancement de $SERVICE..."
  47.     cd $MCPATH
  48.     as_user "cd $MCPATH && screen -h $HISTORY -dmS $SCREEN $INVOCATION"
  49.     sleep 7
  50.     if pgrep -u $USERNAME -f $SERVICE > /dev/null
  51.     then
  52.       echo "$SERVICE est désormais lancé !"
  53.     else
  54.       echo "Erreur ! Impossible de lancer $SERVICE!"
  55.     fi
  56.   fi
  57. }
Advertisement
Add Comment
Please, Sign In to add comment