#!/bin/bash # customhardylamp.sh - # # by dual # # Customizes an Ubuntu 8.04 Server LAMP install # # Usage: # chmod +x customhardylamp.sh # ./customhardylamp.sh | tee custom.log ############################################### #### BEG: Privileged tasks #### function priv_tasks { # Provide proof of execution # and create ubuntu_version if [ ! -f /etc/customlamp ]; then touch /etc/customlamp cat /etc/issue.net > /etc/ubuntu_version fi # Remind sysadmins how long # this version is supported echo '2013-04' > /etc/supported2 # Fix default interpreter echo '>>> Setting interpreter to bash...' rm -f /bin/sh ln -s /bin/bash /bin/sh # Provide custom syntax highlighting for nano echo '>>> Adding syntax highlighting for nano...' wget -q http://dualisanoob.com/linux/dot/nanorc.txt mv -f nanorc.txt /etc/nanorc # Take care of issues and motd echo '>>> Customizing banners...' wget -q http://dualisanoob.com/linux/dot/motd.txt cp -f motd.txt /etc/issue cp -f motd.txt /etc/issue.net mv -f motd.txt /etc/motd # Remove unnecessary packages echo '>>> Removing unnecessary packages...' aptitude -y purge command-not-found command-not-found-data ppp pppconfig pppoeconf # Update and upgrade echo '>>> Updating system...' aptitude update && aptitude -y safe-upgrade # Install sysv-rc-conf echo '>>> Installing sysv-rc-conf...' aptitude -y install sysv-rc-conf # Turn off marks in syslog echo '>>> Configuring syslogd...' sed -i 's/SYSLOGD=""/SYSLOGD="-m 0"/' /etc/default/syslogd # Install ntp echo '>>> Installing ntp...' aptitude install ntp cp -a /etc/ntp.conf /etc/ntp.conf.bak sed -i 's/ntp\.ubuntu\.com/0\.pool\.ntp\.org/' /etc/ntp.conf /etc/init.d/ntp restart # Backup and edit apache2.conf echo '>>> Configuring Apache...' cp -a /etc/apache2/apache2.conf /etc/apache2/apache2.conf.bak sed -i 's/ServerTokens Full/ServerTokens Prod/' /etc/apache2/apache2.conf # Install Perl CGI echo '>>> Installing Perl CGI capability...' aptitude -y install libapache2-mod-perl2 libcgi-perl perl-doc # Take care of nc and telnet echo '>>> Making netcat and telnet non-executable...' chmod 600 /bin/nc /usr/bin/telnet.netkit # Create useful CGI and HTML links echo '>>> Creating cgi-bin and www links...' ln -s /usr/lib/cgi-bin $HOME/cgi ln -s /var/www $HOME/html # Add dlist, dpurge and update utils echo ">>> Installing root's utilities..." echo ' >>> dlist' echo '#!/bin/bash' > $HOME/bin/dlist echo 'dpkg -l | grep $1 | more' >> $HOME/bin/dlist echo ' >>> dpurge' wget -q http://dualisanoob.com/linux/dot/dpurge.sh.txt mv -f dpurge.txt $HOME/bin/dpurge echo ' >>> update' echo '#!/bin/bash' > $HOME/bin/update echo 'aptitude update && aptitude safe-upgrade' >> $HOME/bin/update chmod 700 $HOME/bin/* # Add log directory echo ">>> Adding root's log directory..." mkdir $HOME/log chmod 700 $HOME/log # Closing message/reboot read -p '>>> Would you like to reboot? (y or n) ' INIT6 if [ $INIT6 = 'y' ]; then reboot else echo '>>> Restarting Apache...' /etc/init.d/apache2 restart echo '>>> Done!' exit fi ##### END: Privileged tasks ##### } # Opening message echo echo '>>>' echo '>>> customhardylamp.sh - Customizes an Ubuntu 8.04 Server LAMP install' echo '>>>' echo # Check for LAMP echo '>>> Checking for LAMP...' if [ ! -x /usr/sbin/apache2 ]; then echo '>>> LAMP not detected' echo '>>> Please install Ubuntu 8.04 Server LAMP software' echo '>>> Exiting' exit fi echo '>>> LAMP detected... continuing' # Create personal executable directory if [ ! -d $HOME/bin ]; then echo '>>> Creating personal bin directory...' mkdir $HOME/bin chmod 700 $HOME/bin fi # Set up shell environment echo '>>> Installing bash resource files...' wget -q http://dualisanoob.com/linux/dot/bashrc.txt mv -f bashrc.txt $HOME/.bashrc wget -q http://dualisanoob.com/linux/dot/bash_profile.txt mv -f bash_profile.txt $HOME/.bash_profile wget -q http://dualisanoob.com/linux/dot/bash_logout.txt mv -f bash_logout.txt $HOME/.bash_logout # Perform privileged tasks if [ $UID = '0' ]; then priv_tasks fi # Closing message echo '>>> Done!'