SHARE
TWEET

bukkit.sh

a guest Dec 11th, 2011 84 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2.  
  3. #  Author: TBC_x
  4. # Created: 10-27-2011 15:34:17
  5. # License: You can do whatever you want with this script, respecting laws
  6. # of your country. But if you'll mess up your system, it's YOUR fault!
  7.  
  8. # This script was created for simple preparation GNU screen for run bukkit
  9. # server. This allows to share bukkit console with more users. Users should
  10. # be added in /home/bukkit/.xscreenrc and members of bukkitadmin group.
  11. # Pass user names as arguments. If you want additional changes, do it by hand.
  12.  
  13. # For smooth run /var/run/screen must have mode 755 and GNU screen bust be run
  14. # with SUID bit set. It's disadvantage is less security. When GNU screen with
  15. # SUID can be exploited and do bad stuff (no remote exploits though). So when
  16. # you're using encrypted SSH access your own machine, this shouldn't be any obstacle.
  17.  
  18. # When executed just run 'su -c "screen -AdmS Minecraft /path/to/start/script"
  19. # bukkit'. I'm recommending add it as init script.
  20.  
  21. # Manually adding users: add line in /home/bukkit/.screenrc "acladd USERNAME"
  22. # and add that user in group bukkitadmin too.
  23.  
  24. basedir="/home"
  25. username="bukkit"
  26. groupname="bukkitadmin"
  27. shell="/bin/bash"
  28. users=$@
  29.  
  30. # ===================================================
  31. # === DON'T TOUCH THIS, IT WILL SNAP YOUR HAND!!! ===
  32. # ===================================================
  33.  
  34. function creationtime {
  35.  
  36. groupadd $groupname
  37. useradd -s $shell -mb $basedir -g $groupname $username
  38.  
  39. # Creating base configuration for screen
  40.  
  41. cat > "$basedir/$username/.screenrc" << EOF
  42. defshell $shell
  43. multiuser on
  44. EOF
  45.  
  46. # Adding users from argument
  47.  
  48. for user in $users; do
  49.   if (id $user &> /dev/null); then        # Checking for presence of users in system
  50.     usermod -a -G $groupname $user
  51.     echo acladd $user >> $basedir/$username/.screenrc
  52.   else
  53.     echo "Warning: user $user doesn't exist!"
  54.   fi
  55. done
  56.  
  57. # This is very useful, hopefully you won't experience permissions problems anymore!
  58.  
  59. echo "umask 007" >> $basedir/$username/.bashrc
  60. chown -R $username:$groupname $basedir/$username
  61. chmod -R 770 $basedir/$username
  62.  
  63. }
  64.  
  65. # Some basic checks, testing, if the script can be run.
  66.  
  67. if   [ ! $1 ]; then
  68.     echo "  Usage: bukkit.sh [Users]"
  69.     echo "Example: bukkit.sh bob jack"
  70.     exit 0
  71.  
  72. elif [[ $USER != "root" ]]; then
  73.   echo "You aren't root, this won't work, if you aren't root."
  74.   exit 1
  75.  
  76. elif (id $username &> /dev/null); then
  77.   echo "User $username exists! Stopping..."
  78.   exit 1
  79. fi
  80.  
  81.  
  82.  
  83. creationtime
  84.  
  85. exit 0
  86.  
  87.  
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top