All pastes #24848 Raw Edit

ofer

public shellscript v1 · immutable
#24848 ·published 2005-10-07 14:39 UTC
rendered paste body
#!/bin/bash	echo "This is a /etc/init.d/rc.local file creation script."	echo "This script will create a rc.local file in the /etc/init.d directory"	echo "directory, a place where you can put commands for execution during startup"	echo "The script was written by Ofer Shaked"	echo "Contact me @ ofershaked@myrealbox.com"	echo "Visit me @ http://ilunix.org"	echo "Do you wish to install this script? (yes/no)"	ASK1="yes no"	select yesno in $ASK1; do	if [ "$yesno" = "yes" ]; then		echo "You chose to install this script. Executing request."		echo "Do you wish to use a root account, or sudo command? (root/sudo)"		ASK2="root sudo"		select rootsudo in $ASK2; do		if [ "$rootsudo" = "root" ]; then			if [ `whoami` = "root" ]; then				touch /etc/init.d/rc.local				echo "#!/bin/bash" >> /etc/init.d/rc.local				echo "# Edit this file, and add commands to execute when your computer boots." >> /etc/init.d/rc.local				echo "# Example:" >> /etc/init.d/rc.local				echo "# echo Last Reboot: \`uptime\` >> /home/username/lastreboot" >> /etc/init.d/rc.local				echo "# Use this in order to know when was the last time you rebooted, and get a log of all reboots." >> /etc/init.d/rc.local				chmod +x /etc/init.d/rc.local				update-rc.d rc.local defaults 80				echo "All done! you can now edit /etc/init.d/rc.local if you want to add something that will run when your computer boots"			else				echo "If you wish to use this script with a root account,"				echo "run it as root. using \"su\" command."				echo "The script is currently running by the user `whoami`"			fi		elif [ "$rootsudo" = "sudo" ]; then			echo "You chose to run this script with the \"sudo\" command"			echo "Please type your username's password when asked."			sudo touch /etc/init.d/rc.local			sudo echo "#!/bin/bash" >> /etc/init.d/rc.local			sudo echo "# Edit this file, and add commands to execute when your computer boots." >> /etc/init.d/rc.local			sudo echo "# Example:" >> /etc/init.d/rc.local			sudo echo "# echo Last Reboot: \`uptime\` >> /home/username/lastreboot" >> /etc/init.d/rc.local			sudo echo "# Use this in order to know when was the last time you rebooted, and get a log of all reboots." >> /etc/init.d/rc.local			sudo chmod +x /etc/init.d/rc.local			sudo update-rc.d rc.local defaults 80			echo "All done! you can now edit /etc/init.d/rc.local if you want to add something that will run when your computer boots"		else			"Please reply with \"root\" or \"sudo\" only."		fi	elif [ "$yesno" = "no" ]; then		echo "You chose not to install this script."		echo "Bye bye."	else		echo "Please reply with \"yes\" or \"no\" only"	fidone