Annotation of mtctl/installer.sh, Revision 1.1
1.1 ! bountyht 1: OS="`uname`"
! 2: ROOTCMD='sudo'
! 3: case $OS in
! 4: 'Linux')
! 5: SHLL='bash'
! 6: ;;
! 7: 'FreeBSD')
! 8: SHLL='sh'
! 9: ;;
! 10: 'OpenBSD')
! 11: SHLL='ksh'
! 12: ROOTCMD='doas'
! 13: ;;
! 14: *)
! 15: exit
! 16: ;;
! 17: esac
! 18:
! 19: if [[ "`id -u`" -eq 0 ]]; then
! 20: echo -e "Checking Root User(Oke)"
! 21: else
! 22: echo -e "Checking Root User(Failed). Switching to root user"
! 23: PROFILE_SHELL=`sh -c 'ps -p $$ -o ppid=' | xargs ps -o comm= -p`
! 24:
! 25: if [ "$PROFILE_SHELL" \!= "$SHLL" ]; then
! 26: exec curl -sSL https://cvsweb.planetofnix.com/cgi-bin/cvsweb/~checkout~/mtctl/installer.sh?content-type=text/plain | $ROOTCMD $SHLL "$@"
! 27: else
! 28: exec $ROOTCMD $SHLL "$0" "$@"
! 29: fi
! 30: exit $?
! 31: fi
! 32:
! 33: echo -e "\nmtctl Installer, Starting up..."
! 34:
! 35: echo -e "\nInsert in the following questions the corresponding answer:\n"
! 36: echo -n 'MTUser: '; read MTUSER
! 37: echo -n 'Use custom build minetest folder (yes/no): '; read MTBUILD
! 38: if [ "$MTBUILD" == "YES" ]; then MTBUILD='yes'; fi; if [ "$MTBUILD" == "NO" ]; then MTBUILD='no'; fi
! 39: if [ "$MTBUILD" == "yes" ]; then EXAMPLEDIR="/home/$MTUSER/minetest"; else EXAMPLEDIR="/home/$MTUSER/.minetest"; fi
! 40: echo -n "Insert the path to the minetest folder(eg. $EXAMPLEDIR): "; read MTLOCATION
! 41: SHaLL="`which $SHLL`"
! 42:
! 43: if [ \! -f mtctl_default.sh ]; then wget -O mtctl_default.sh "https://cvsweb.planetofnix.com/cgi-bin/cvsweb/~checkout~/mtctl/mtctl_default.sh?content-type=text/plain"; fi
! 44:
! 45: VARS="#!$SHaLL\nMTUSER=\"$MTUSER\"\nMTBUILD=\"$MTBUILD\"\nMTDIR=\"$MTLOCATION\"\n"
! 46: echo -e "$VARS" > mtctl
! 47: cat mtctl_default.sh >> mtctl
! 48:
! 49: chmod 555 mtctl
! 50: $ROOTCMD install mtctl /usr/bin/mtctl
! 51:
! 52: if [ "$SHLL" == "bash" ]; then
! 53: if [ \! -f mtctl-completion.bash ]; then wget -O mtctl-completion.bash "https://cvsweb.planetofnix.com/cgi-bin/cvsweb/~checkout~/mtctl/mtctl-completion.bash?content-type=text/plain"; fi
! 54: MTDIR="$MTLOCATION/worlds"; MTDIR=${MTDIR//\//\\\/}
! 55: cat mtctl-completion.bash | sed -e "s/{WORLDFOLDER}/$MTDIR/" > tmpfile.txt; mv tmpfile.txt mtctl-completion.bash
! 56: $ROOTCMD grep -q "mtctl" /usr/share/bash-completion/bash_completion; [ $? -eq 0 ] || \
! 57: $ROOTCMD cat /usr/share/bash-completion/bash_completion >> mtctl-completion.bash && $ROOTCMD mv mtctl-completion.bash /usr/share/bash-completion/bash_completion
! 58: fi
! 59:
! 60: echo -e "Done!\n\nThanks for installing mtctl!\nYou can now use it by running $ mtctl"
CVSweb