#!/bin/bash # # ubuntu-irlp-reinstall - v.0.8 Robert Pectol (kk7av) # http://rob.pectol.com/irlp/irlp-echolink-install-files/ubuntu-irlp-reinstall # # This IRLP installer script was specifically written for Ubuntu Linux systems. # It will NOT work on other distributions! It was heavily modified from the # original irlp-reinstall script found on the FC5 official IRLP release # distribution. # ##################################################################################### # Make sure we are ROOT! if [ "$UID" != "0" ]; then echo -e "\E[1;33mThis Ubuntu IRLP installer must be executed with root privileges! Exiting...\E[32;0m" exit 1 fi # Make sure this is an Ubuntu System OS_FILE_LOC="`ls /etc | grep release`" OS_INFO="`cat /etc/$OS_FILE_LOC`" IS_UBUNTU="`echo $OS_INFO | egrep 'Debian|Ubuntu'`" if [ "$IS_UBUNTU" == "" ]; then echo -e "\E[1;33mNon-Ubuntu system detected! This script CANNOT be run on a non-Ubuntu system! Exiting...\E[32;0m" exit 1 fi clear # disclaimer, etc. echo "" echo "" echo "This script performs a re-install of the IRLP software. It can" echo "only be performed if you have a backup of the security keyfile," echo "as this script will not regenerate a PGP key. The node backup" echo "file should contain the appropriate keyfile(s)." echo echo "* Please note - This is not considered an official install of IRLP" echo " since it deviates from the, "preferred" Linux Distribution as" echo " set forth by the IRLP designer/maintainers. For this reason," echo " you must not expect the maintainers to support it. Basically," echo " you are on your own with it! But don't worry, Ubuntu Linux is" echo " probably more secure and less prone to problems anyway. :-)" echo " That being said, this disclaimer must be considered and under-" echo " stood before proceeding. Furthermore, I accept absolutely NO" echo " responsibility for your use of this script. If the information" echo " contained herein is incorrect or interpreted incorrectly, and" echo " causes undesired results, I will NOT be held liable in ANY way" echo " whatsoever. In short, USE AT YOUR OWN RISK!" echo echo "To verify that you understand the above statements, please type" echo -n "ACCEPT (in all capitals) and press ENTER : " ; read accept_or_not echo if [ "$accept_or_not" != "ACCEPT" ] ; then echo "Please re-run this reinstaller script and make sure you understand and" echo "comply with the disclaimer(s) before proceeding." exit 1 fi clear # Sets the install directory ID=/home/irlp # enable extra repos echo "enabling extra package repositories..." if [ ! -f /etc/apt/sources.list_orig ]; then cp /etc/apt/sources.list /etc/apt/sources.list_orig fi egrep -v 'deb cdrom|backports|deb file' /etc/apt/sources.list | egrep 'deb http|deb ftp|deb-src' | sed 's/#//g; s/^[ \t]*//;s/[ \t]*$//' > /tmp/sources.list mv -f /tmp/sources.list /etc/apt/sources.list # make sure the package database is up to date echo "refreshing packages database..." apt-get update # Sets the IP of the download server (requires the use of ncftp so we make sure it's available first) echo "checking for ncftpget..." if ! (which ncftpget &>/dev/null) ; then echo "WARNING: Missing - ncftpget" echo "Installing ncftp utilities..." apt-get install ncftp fi if (which ncftpget &>/dev/null) ; then echo "ncftpget installed [ OK ]" else echo "[ FAIL ]" echo "ncftp could not be installed. You need to figure out why, or else" echo "install it manually (apt-get install ncftp) before trying to restore" echo "your node with this script." echo echo "Script Terminated" exit 1 fi echo "detecting download server IP address..." ncftpget ftp://ftp.irlp.net/pub/install/irlp-install >&/dev/null 2>&1 SERVERIP=`cat ./irlp-install 2>/dev/null | egrep '^SERVERIP=' | cut -d '=' -f2` rm -f ./irlp-install >&/dev/null 2>&1 if [ "$SERVERIP" == "" ]; then SERVERIP=208.67.253.178 echo "Server IP could NOT be detected! Using default of: $SERVERIP" else echo "Server IP detected as: $SERVERIP" fi sleep 3 # set environment file variable ENVFILE=$ID/custom/environment clear # locate node backup file if [ ! -f /tmp/irlp_backup.tgz ]; then echo "A node backup file was NOT found in the system /tmp directory." echo "If you have a floppy with the backup from your old node on it," echo "please put it in the floppy drive now, and then press Enter." read echo echo "Mounting floppy and copying file .... " if [ ! -d /media ]; then mkdir /media >&/dev/null 2>&1 fi if [ ! -d /media/floppy ]; then mkdir /media/floppy >&/dev/null 2>&1 fi if [ -a /dev/fd0 ]; then mount /dev/fd0 /media/floppy else mount /dev/floppy /media/floppy fi if [ ! -f /media/floppy/irlp_backup.tgz ]; then echo "could NOT find a suitable backup file! If you continue to have trouble loading it from a" echo "floppy disk, please manually copy it to the system /tmp directory and then run this script" echo "again. Exiting..." umount /media/floppy >&/dev/null 2>&1 exit 1 fi cp -f /media/floppy/irlp_backup.tgz /tmp umount /media/floppy >&/dev/null 2>&1 if [ -f /tmp/irlp_backup.tgz ]; then echo "node backup file copied successfully!" continue="yes" else echo "node backup file was NOT copied successfully! This may mean that the floppy disk is" echo "corrupt or un-readable. If you continue to have trouble loading it from a floppy" echo "disk, please manually copy it to the system /tmp directory and then run this script" echo "again. Exiting..." exit 1 fi else echo "A node backup file was found in the system /tmp directory." echo "Would you like to use that backup file to restore your node? (y/N): " read yesorno echo "" if [[ "$yesorno" == "y" || "$yesorno" == "Y" ]]; then continue="yes" else continue="no" fi fi # continue or not if [ "$continue" == "no" ]; then echo "Ok. Node backup file in /tmp will not be used. Please replace it with the one you" echo "wish to use and then run this script again. Exiting..." exit 1 else echo "" echo "Proceeding to restore node..." fi sleep 3 clear echo "" echo " IRLP has a series of requirements that must be met before it can run successfully under" echo " Ubuntu Linux. These requirements will now be checked. If something is missing, an attempt" echo " to retrieve and install the missing item(s) will be performed. Also, any necessary changes" echo " to the default settings will also be applied and verified. The validation process requires" echo " that this box be connected to the Internet so that the proper packages can be retrieved and" echo " installed." echo "" echo "Press ENTER to continue." read echo "" echo "" ##### ##### check for sox ##### echo "checking for sox..." if ! (which sox &>/dev/null) ; then echo "WARNING: Missing - sox" echo "Installing sox audio utilities..." apt-get install sox fi if (which sox &>/dev/null) ; then echo "sox installed [ OK ]" else echo "[ FAIL ]" echo "sox could not be installed. You need to figure out why, or else" echo "install it manually (apt-get install sox) before trying to restore" echo "your node with this script." echo echo "Script Terminated" exit 1 fi sleep 2 ##### ##### check for gawk ##### echo "checking for GNU-awk (gawk)..." if ! (which gawk &>/dev/null) ; then echo "WARNING: Missing - gawk" echo "Installing GNU-awk (gawk)..." apt-get install gawk fi if (which gawk &>/dev/null) ; then echo "gawk installed [ OK ]" else echo "[ FAIL ]" echo "gawk could not be installed. You need to figure out why, or else" echo "install it manually (apt-get install gawk) before trying to restore" echo "your node with this script." echo echo "Script Terminated" exit 1 fi sleep 2 ##### ##### check for aumix ##### echo "checking for aumix..." if ! (which aumix &>/dev/null) ; then echo "WARNING: Missing - aumix" echo "Installing aumix curses-based mixer utility..." apt-get install aumix fi if (which aumix &>/dev/null) ; then echo "aumix installed [ OK ]" else echo "[ FAIL ]" echo "aumix could not be installed. You need to figure out why, or else" echo "install it manually (apt-get install aumix) before trying to restore" echo "your node with this script." echo echo "Script Terminated" exit 1 fi sleep 2 ##### ##### check for usleep ##### echo "checking for usleep..." if ! (which usleep &>/dev/null) ; then echo "WARNING: Missing - usleep" echo "Installing usleep utility..." wget http://rob.pectol.com/irlp/irlp-echolink-install-files/usleep mv ./usleep /bin/usleep chmod 755 /bin/usleep fi if (which usleep &>/dev/null) ; then echo "usleep installed [ OK ]" else echo "[ FAIL ]" echo "usleep could not be installed. You need to figure out why, or else" echo "install it manually before trying to restore your node with this script." echo "Since Ubuntu does not have usleep in the official repos, you will need" echo "to grab it here: " echo "http://rob.pectol.com/irlp/irlp-echolink-install-files/usleep" echo echo "Once you have retrieved a copy of usleep, you will need to move it into your" echo "/bin directory and make it executable (chmod 755 /bin/usleep). After you've" echo "done this, re-run this IRLP restore script." echo echo "Script Terminated" exit 1 fi sleep 2 ##### ##### check for configured sound device ##### echo "checking for configured sound device..." if ! (echo 1>/dev/audio >/dev/null 2>&1) && [ "$1" != "nosound" ] ; then echo "[ FAIL ]" echo "The script has detected that your sound card is not configured." echo "You must exit and fix this. I'm leaving it up to you to figure it out!" echo echo "If your sound card is working fine, and you still get this message, " echo "then run the install script with the argument, 'nosound' as in: " echo "./ubuntu-irlp-reinstall nosound" echo echo -n "Press ENTER to exit."; read exit 1 else if [ "$1" = "nosound" ] ; then echo "Sound card detection skipped" else echo "sound device configured [ OK ]" fi fi sleep 2 ##### ##### check for wget ##### echo "checking for wget..." if ! (which wget &>/dev/null) ; then echo "WARNING: Missing - wget Internet Browser" echo "Installing wget..." apt-get install wget fi if (which wget &>/dev/null) ; then echo "wget installed [ OK ]" else echo "[ FAIL ]" echo "wget could not be installed. You need to figure out why, or else" echo "install it manually (apt-get install wget) before trying to restore" echo "your node with this script." echo echo "Script Terminated" exit 1 fi sleep 2 ##### ##### check for lynx ##### echo "checking for lynx..." if ! (which lynx &>/dev/null) ; then echo "WARNING: Missing - lynx Internet Browser" echo "Installing lynx..." apt-get install lynx fi if (which lynx &>/dev/null) ; then echo "lynx installed [ OK ]" else echo "[ FAIL ]" echo "lynx could not be installed. You need to figure out why, or else" echo "install it manually (apt-get install lynx) before trying to restore" echo "your node with this script." echo echo "Script Terminated" exit 1 fi sleep 2 ##### ##### check for sed ##### echo "checking for sed (stream editor)..." if ! (which sed &>/dev/null) ; then echo "WARNING: Missing - sed (stream editor)" echo "Installing sed..." apt-get install sed fi if (which sed &>/dev/null) ; then echo "sed installed [ OK ]" else echo "[ FAIL ]" echo "sed could not be installed. You need to figure out why, or else" echo "install it manually (apt-get install sed) before trying to restore" echo "your node with this script." echo echo "Script Terminated" exit 1 fi sleep 2 ##### ##### check for pico/nano ##### echo "checking for pico text editor..." if ! (which pico &>/dev/null) ; then echo "WARNING: Missing - pico" echo "Installing nano (pico text editor clone)..." apt-get install nano fi if ! (which pico &>/dev/null) ; then ln -s `which nano` /usr/bin/pico fi if (which pico &>/dev/null) ; then echo "pico installed [ OK ]" else echo "[ FAIL ]" echo "pico could not be installed. You need to figure out why, or else" echo "install it manually (apt-get install nano) before trying to restore" echo "your node with this script." echo echo "Script Terminated" exit 1 fi sleep 2 ##### ##### check for netcat ##### echo "checking for netcat..." if ! (which nc &>/dev/null) ; then echo "WARNING: Missing - netcat" echo "Installing netcat..." apt-get install netcat fi if (which nc &>/dev/null) ; then echo "netcat installed [ OK ]" if [ ! -e /usr/bin/nc ]; then echo "creating symlink..." ln -s `which nc` /usr/bin/nc > /dev/null 2>&1 if [ ! -e /usr/bin/nc ]; then echo "symlink NOT created!" else echo "symlink created [ OK ]" fi fi else echo "[ FAIL ]" echo "netcat could NOT be installed. You need to figure out why, or else" echo "install it manually (apt-get install netcat) before trying to restore" echo "your node with this script." echo echo "Script Terminated" exit 1 fi # This cleans up the ugly BASHRC problem where root does not have # a pretty prompt. if [ ! -f /root/.bash_profile ] ; then if [ -f /etc/bashrc ]; then ln -s /etc/bashrc /root/.bash_profile fi fi # THIS CHECKS TO MAKE SURE YOUR HOSTNAME RESOLVES, # and ADDS A SIMPLE LINE TO THE HOSTS FILE IF NOT CONTINUE="NO" echo "checking to make sure hostname resolves..." while [ "$CONTINUE" = "NO" ] ; do if ! (ping -c1 `hostname` > /dev/null 2>&1) ; then echo "The script has detected that your hostname = " `hostname` " does not resolve." echo echo "This is required for the irlp-install to continue. " echo echo -n "Would you like the script to try to add a line to the hosts file to help? : (Y/n)" ; read YESNO if [ "$YESNO" = "y" ] || [ "$YESNO" = "Y" ] || [ "$YESNO" = "" ] ; then echo echo "Adding line : 127.0.0.1 " `hostname` " to /etc/hosts" echo "127.0.0.1 localhost.localdomain localhost "`hostname` >> /etc/hosts else echo echo "This line is required for IRLP to work." echo "If you are still having troubles please email installs@irlp.net" echo echo -n "Press ENTER to exit."; read exit 1 fi else CONTINUE="YES" echo "hostname resolves [ OK ]" echo echo fi done echo echo "All prerequisites look satisfied. Press ENTER to continue installing IRLP..." read clear echo "" echo "Your IRLP node really should have a Secure Shell Server if you plan on remotely" echo "administering it. Most nodes require this. Would you like to install this? (Y/n): " read install_openssh-server if [[ "$install_openssh-server" == "n" || "$install_openssh-server" == "N" ]]; then echo "Ok. NOT checking for/installing a Secure Shell Server..." else ##### ##### check for openssh-server ##### echo "checking for openssh-server..." if ! (which sshd &>/dev/null) ; then echo "WARNING: Missing - openssh-server" echo "Installing openssh-server..." apt-get install openssh-server else echo "Already installed!" fi if (which sshd &>/dev/null) ; then echo "openssh-server installed [ OK ]" echo "press enter to continue." read else echo "[ FAIL ]" echo "openssh-server could not be installed. You need to figure out why, or else" echo "install it manually (apt-get install openssh-server). This is NOT a critical" echo "error and will not harm the install. You may safely proceed with the IRLP" echo "install but if you want remote shell access to your node, openssh-server will" echo "need to be installed afterwards." echo echo "Press enter to continue." read fi sleep 2 fi echo -n Adding repeater user ... sleep 1 groupadd repeater /usr/sbin/useradd -d /home/irlp -g repeater repeater >/dev/null 2>&1 echo " done." echo -n Adding repeater user to the sys and lp groups ... sleep 1 /usr/sbin/usermod -d /home/irlp -s /bin/bash -G sys,lp,adm,repeater repeater >/dev/null 2>&1 echo " done." echo -n "Changing permissions of sound card device files in /dev ..." sleep 1 chmod 660 /dev/mixer* /dev/dsp* /dev/audio* chown root.sys /dev/mixer* /dev/dsp* /dev/audio* echo " done." echo "adding parport device if it doesn't already exist..." sleep 1 if ! [ `cat /etc/modules | grep ppdev` ]; then echo "ppdev" >> /etc/modules modprobe ppdev fi echo " done." echo -n Making IRLP directory structure ... sleep 1 mkdir $ID >/dev/null 2>&1 mkdir $ID/local >/dev/null 2>&1 mkdir $ID/custom >/dev/null 2>&1 mkdir $ID/bin >/dev/null 2>&1 mkdir $ID/run >/dev/null 2>&1 mkdir $ID/audio >/dev/null 2>&1 mkdir $ID/scripts >/dev/null 2>&1 mkdir $ID/log >/dev/null 2>&1 touch $ID/log/messages >/dev/null 2>&1 mkdir $ID/.pgp >/dev/null 2>&1 mkdir $ID/irlp-install-files >/dev/null 2>&1 echo " done." echo -n Setting up PGP base directory information ... sleep 1 rm -f $ID/.pgp/* >/dev/null 2>&1 touch $ID/.pgp/pgpdoc1.txt touch $ID/.pgp/pgpdoc2.txt touch $ID/.pgp/secring.pgp touch $ID/.pgp/pubring.pgp touch $ID/.pgp/config.txt echo " done." echo Downloading IRLP software tarfiles into $ID/ ... rm -fr $ID/*.tgz rm -fr $ID/*.pgp # change to the new home directory cd $ID #Added Oct13,2002 - This fix to d/l all the files at once, so we #do not have to wait for broken DNS machines. echo "Downloading the files from the server" ncftpget $SERVERIP $ID /pub/irlpv2.0/Baseaudio.tgz\ /pub/irlpv2.0/Bin.tgz /pub/irlpv2.0/Custom.tgz\ /pub/irlpv2.0/Scripts.tgz /pub/irlpv2.0/pubring.pgp echo Uncompressing Install Images .... echo -n "DIRECTORIES : custom, " if [ -f $ID/Custom.tgz ] ; then tar -zxf $ID/Custom.tgz else echo echo File Custom.tgz is MISSING.... exiting exit 1 fi echo -n "bin, " if [ -f $ID/Bin.tgz ] ; then tar -zxf $ID/Bin.tgz else echo echo File Bin.tgz is MISSING.... exiting exit 1 fi echo -n "audio (base), " if [ -f $ID/Baseaudio.tgz ] ; then tar -zxf $ID/Baseaudio.tgz else echo echo File Baseaudio.tgz MISSING.... exiting exit 1 fi echo "scripts, " if [ -f $ID/Scripts.tgz ] ; then tar -zxf $ID/Scripts.tgz else echo echo File Scripts.tgz is MISSING.... exiting exit 1 fi echo -n "pgp, " if [ -f $ID/pubring.pgp ] ; then cp -f $ID/pubring.pgp $ID/.pgp/pubring.pgp else echo echo File pubring.pgp is MISSING.... exiting exit 1 fi echo "done." echo -n "Cleaning up install files ..." mv -f $ID/*.tgz $ID/irlp-install-files echo " done." #### Links for aumixrc #### echo -n Creating symlinks for aumix audio mixer ... touch /etc/aumixrc ln -sf /etc/aumixrc /home/irlp/.aumixrc ln -sf /etc/aumixrc /root/.aumixrc echo " done." #### Add line to rc.local #### if ! (cat /etc/init.d/rc.local | grep rc.irlp > /dev/null 2>&1) ; then echo -n Adding start lines to rc.local ... echo "# THIS LINE ADDED FOR THE IRLP SYSTEM" >> /etc/init.d/rc.local echo $ID/custom/rc.irlp >> /etc/init.d/rc.local echo " done." fi #### Adding irlp to the INETD/XINETD services file #### if ! (cat /etc/services | grep irlp_update > /dev/null 2>&1) ; then echo -n "Changing the inetd services file for IRLP ..." echo "# Added by the IRLP autoinstaller" >> /etc/services echo "irlp 15425/tcp #added by irlp.install" >> /etc/services echo " done." fi #### Unzipping the old node files into the new directory tree #### cp /tmp/irlp_backup.tgz /home/irlp/ tar -zxvf /home/irlp/irlp_backup.tgz rm /home/irlp/irlp_backup.tgz #This runs an rsync to update the files on the node to what is currently #on the server, to make sure we are not too far behind in updates. Some #installs from the CD will be so old they will not even have the right code #to update from a viable server, and will require rebuilding from the server. echo "Performing an update of files on the system to ensure they are up to date ..." chmod +x $ID/bin/rsync $ID/bin/rsync -Wazv --exclude=stn*.wav $SERVERIP::irlp $ID echo "done." #### Setting File Permissions #### echo -n Setting file permissions for IRLP files ... chmod 660 "$ID"/audio/* chmod 750 "$ID"/bin/* chmod 750 "$ID"/scripts/* chmod 750 "$ID"/custom/* chmod 750 "$ID" chown -R repeater.repeater "$ID"/* chown repeater.repeater "$ID" chmod 750 "$ID"/custom/rc.irlp chown root.root "$ID"/custom/rc.irlp chmod 750 "$ID"/custom/environment chown root.repeater "$ID"/custom/environment chown repeater.repeater "$ID"/.pgp chown -R repeater.repeater "$ID"/.pgp/* echo " done." echo -n Setting profile for user repeater ... echo ". $ID/custom/environment" >> $ID/.bash_profile echo ". $ID/.bashrc" >> $ID/.bash_profile cp /etc/skel/.bashrc $ID/.bashrc chown repeater.repeater $ID/.bash* chmod 755 $ID/.bash_profile echo " done." # modifies udev rules for audio device nodes if (grep 'GROUP=\"audio\"' /etc/udev/rules.d/40-permissions.rules | grep 'SUBSYSTEM==\"sound\"' >&/dev/null 2>&1) ; then cp /etc/udev/rules.d/40-permissions.rules /root/udev_permissions.rules.bak sed "s-SUBSYSTEM==\"sound\", GROUP=\"audio\"-SUBSYSTEM==\"sound\", GROUP=\"sys\"-" /etc/udev/rules.d/40-permissions.rules > /tmp/40-permissions.rules mv -f /tmp/40-permissions.rules /etc/udev/rules.d/40-permissions.rules echo "udev rule for sound devices has been modified. The old udev rules file was saved in: '/root/udev_permissions.rules.bak'" else echo "udev rule for sound devices has already been properly set." fi #THIS SCRIPT REMOVES KMOD from the cron.d folder. echo "removing KMOD from cron..." if [ -f /etc/cron.d/kmod ] ; then rm -f /etc/cron.d/kmod echo "KMOD removed from /etc/cron.d/" fi echo "Finishing install..." sleep 1 cs=`cat /home/irlp/custom/environment | grep 'export CALLSIGN' | cut -d '=' -f2` nn=`cat /home/irlp/custom/environment | grep 'export STATIONID' | cut -d '=' -f2` os=`wget http://rob.pectol.com/irlp/machine_id.sh > /dev/null 2>&1 && sh ./machine_id.sh` if [ "$os" == "" ]; then os=`uname -r` fi result=`wget --post-data="value1=$cs&value2=$nn&value3=ubuntu-irlp-reinstall&value4=install&value5=$os" \ http://rob.pectol.com/cgi-bin/dl_stats.cgi >&/dev/null 2>&1; cat ./dl_stats.cgi; rm -f ./dl_stats.cgi` echo $result sleep 4 clear echo "IRLP FILES HAVE BEEN INSTALLED" echo echo "You can now perform the steps in the after installation document located at:" echo "http://www.irlp.net/new-install/ " echo echo "CONGRATULATIONS on installing IRLP under Ubuntu Linux! Enjoy! :-)" exit 0