[BACK]Return to installer.sh CVS log [TXT][DIR] Up to [local] / mtctl

File: [local] / mtctl / installer.sh (download)

Revision 1.1.1.1 (vendor branch), Tue Aug 31 17:00:08 2021 UTC (2 years, 7 months ago) by bountyht
Branch: miniontoby
CVS Tags: start
Changes since 1.1: +0 -0 lines

Initial version from Miniontoby

OS="`uname`"
ROOTCMD='sudo'
case $OS in
	'Linux')
		SHLL='bash'
		;;
	'FreeBSD')
		SHLL='sh'
		;;
	'OpenBSD')
		SHLL='ksh'
		ROOTCMD='doas'
		;;
	*)
		exit
		;;
esac

if [[ "`id -u`" -eq 0 ]]; then
	echo -e "Checking Root User(Oke)"
else
	echo -e "Checking Root User(Failed). Switching to root user"
	PROFILE_SHELL=`sh -c 'ps -p $$ -o ppid=' | xargs ps -o comm= -p`

	if [ "$PROFILE_SHELL" \!= "$SHLL" ]; then
		exec curl -sSL https://cvsweb.planetofnix.com/cgi-bin/cvsweb/~checkout~/mtctl/installer.sh?content-type=text/plain | $ROOTCMD $SHLL "$@"
	else
		exec $ROOTCMD $SHLL "$0" "$@"
	fi
	exit $?
fi

echo -e "\nmtctl Installer, Starting up..."

echo -e "\nInsert in the following questions the corresponding answer:\n"
echo -n 'MTUser: '; read MTUSER
echo -n 'Use custom build minetest folder (yes/no): '; read MTBUILD
if [ "$MTBUILD" == "YES" ]; then MTBUILD='yes'; fi; if [ "$MTBUILD" == "NO" ]; then MTBUILD='no'; fi
if [ "$MTBUILD" == "yes" ]; then EXAMPLEDIR="/home/$MTUSER/minetest"; else EXAMPLEDIR="/home/$MTUSER/.minetest"; fi
echo -n "Insert the path to the minetest folder(eg. $EXAMPLEDIR): "; read MTLOCATION
SHaLL="`which $SHLL`"

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

VARS="#!$SHaLL\nMTUSER=\"$MTUSER\"\nMTBUILD=\"$MTBUILD\"\nMTDIR=\"$MTLOCATION\"\n"
echo -e "$VARS" > mtctl
cat mtctl_default.sh >> mtctl

chmod 555 mtctl
$ROOTCMD install mtctl /usr/bin/mtctl

if [ "$SHLL" == "bash" ]; then
	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
	MTDIR="$MTLOCATION/worlds"; MTDIR=${MTDIR//\//\\\/}
	cat mtctl-completion.bash  | sed -e "s/{WORLDFOLDER}/$MTDIR/" > tmpfile.txt; mv tmpfile.txt mtctl-completion.bash
	$ROOTCMD grep -q "mtctl" /usr/share/bash-completion/bash_completion; [ $? -eq 0 ] || \
		$ROOTCMD cat /usr/share/bash-completion/bash_completion >> mtctl-completion.bash && $ROOTCMD mv mtctl-completion.bash /usr/share/bash-completion/bash_completion
fi

echo -e "Done!\n\nThanks for installing mtctl!\nYou can now use it by running $ mtctl"