Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Author: TBC_x
- # Created: 10-27-2011 15:34:17
- # License: You can do whatever you want with this script, respecting laws
- # of your country. But if you'll mess up your system, it's YOUR fault!
- # This script was created for simple preparation GNU screen for run bukkit
- # server. This allows to share bukkit console with more users. Users should
- # be added in /home/bukkit/.xscreenrc and members of bukkitadmin group.
- # Pass user names as arguments. If you want additional changes, do it by hand.
- # For smooth run /var/run/screen must have mode 755 and GNU screen bust be run
- # with SUID bit set. It's disadvantage is less security. When GNU screen with
- # SUID can be exploited and do bad stuff (no remote exploits though). So when
- # you're using encrypted SSH access your own machine, this shouldn't be any obstacle.
- # When executed just run 'su -c "screen -AdmS Minecraft /path/to/start/script"
- # bukkit'. I'm recommending add it as init script.
- # Manually adding users: add line in /home/bukkit/.screenrc "acladd USERNAME"
- # and add that user in group bukkitadmin too.
- basedir="/home"
- username="bukkit"
- groupname="bukkitadmin"
- shell="/bin/bash"
- users=$@
- # ===================================================
- # === DON'T TOUCH THIS, IT WILL SNAP YOUR HAND!!! ===
- # ===================================================
- function creationtime {
- groupadd $groupname
- useradd -s $shell -mb $basedir -g $groupname $username
- # Creating base configuration for screen
- cat > "$basedir/$username/.screenrc" << EOF
- defshell $shell
- multiuser on
- EOF
- # Adding users from argument
- for user in $users; do
- if (id $user &> /dev/null); then # Checking for presence of users in system
- usermod -a -G $groupname $user
- echo acladd $user >> $basedir/$username/.screenrc
- else
- echo "Warning: user $user doesn't exist!"
- fi
- done
- # This is very useful, hopefully you won't experience permissions problems anymore!
- echo "umask 007" >> $basedir/$username/.bashrc
- chown -R $username:$groupname $basedir/$username
- chmod -R 770 $basedir/$username
- }
- # Some basic checks, testing, if the script can be run.
- if [ ! $1 ]; then
- echo " Usage: bukkit.sh [Users]"
- echo "Example: bukkit.sh bob jack"
- exit 0
- elif [[ $USER != "root" ]]; then
- echo "You aren't root, this won't work, if you aren't root."
- exit 1
- elif (id $username &> /dev/null); then
- echo "User $username exists! Stopping..."
- exit 1
- fi
- creationtime
- exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement