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

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

Revision 1.4, Tue Oct 19 10:05:56 2021 UTC (2 years, 6 months ago) by miniontoby
Branch: MAIN
Changes since 1.3: +8 -7 lines

Update 1.3: check changelog.txt for more info!

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
		curl -sSL https://ircforever.org/mtctl.php | $ROOTCMD $SHLL "$@"
	else
		$ROOTCMD $SHLL "$0" "$@"
	fi
	exit $?
fi

echo -e "\nmtctl Installer, Starting up..."
SHaLL="`which $SHLL`"

if [ \! -f mtctl_default.sh ]; then curl -sO mtctl_default.sh "https://cvsweb.planetofnix.com/cgi-bin/cvsweb/~checkout~/mtctl/mtctl_default.sh?content-type=text/plain"; fi

VARS="#!$SHaLL\n"
echo -e "$VARS" > mtctl
cat mtctl_default.sh >> mtctl
rm mtctl_default.sh

chmod 555 mtctl
install mtctl /usr/bin/mtctl
mkdir -p /etc/mtctl
rm mtctl

if [ "$SHLL" == "bash" ]; then
	apt-get install rsync
	if [ \! -f mtctl-completion.bash ]; then curl -sO mtctl-completion.bash "https://cvsweb.planetofnix.com/cgi-bin/cvsweb/~checkout~/mtctl/mtctl-completion.bash?content-type=text/plain"; fi
	mkdir -p /etc/bash_completion.d
	mv mtctl-completion.bash /etc/bash_completion.d/mtctl-completion
	. /etc/bash_completion.d/mtctl-completion
elif [ "$SHLL" == "ksh" ]; then
	if [ "`which rsync 2> /dev/null`" == "" ]; then
		pkg_delete rsync
	fi
	pkg_add rsync--
fi

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