Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Web Server Configuration Script.
- # Variables:
- WWWROOT="/home/premise/core"
- APACHEROOT="/etc/httpd"
- APACHECONFD="/etc/httpd/conf.d"
- APACHECONF="/etc/httpd/conf"
- PHPADMIN="/usr/share/phpMyAdmin"
- MYSQLDATABASES="/var/lib/mysql"
- SSLCONFIGS="/etc/pki/tls"
- SSLDEFAULTKEYS="/etc/pki/tls/misc"
- BACKUPDIR="/home/premise/core/backup"
- FILELIMIT="2M"
- #Resources
- DESCRIPTIONS=""
- # Default command:
- TEXT="gedit"
- EDITTEXT="gedit"
- DIR="nautilus --browser"
- function mainmenu {
- clear
- echo -e "\E[34;3m:::Web Server Administration - Main Menu :::" #BOLD BLUE
- echo "============================================"
- echo ""
- echo -e "\E[31;3mType a number and press enter to view a section:" #RED
- echo -e "\E[36;2m" #Light Green
- echo -e "1.) Help"
- echo -e "2.) Directories"
- echo -e "3.) Configuration Menu"
- echo -e "4.) Backup Menu"
- echo -e "5.) Settings"
- echo -e "6.) Exit"
- read opt
- if [ "$opt" = "1" ]; then
- helpmenu
- elif [ "$opt" = "2" ]; then
- directorymenu
- elif [ "$opt" = "3" ]; then
- confmenu
- elif [ "$opt" = "4" ]; then
- backupmenu
- elif [ "$opt" = "5" ]; then
- settingsmenu
- elif [ "$opt" = "6" ]; then
- exit
- else
- mainmenu
- fi
- }
- ############################################################
- function directorymenu {
- clear
- echo -e "\E[34;3m:::Web Server Administration - Directory Menu :::" #BOLD BLUE
- echo "============================================"
- echo ""
- echo -e "\E[31;3mDirectory Menu:" #RED
- echo -e "\E[36;2m" #Light Green
- echo -e "1.) Directory Descriptions"
- echo -e -n "2.) WWW Root "
- echo -e $WWWROOT
- echo -e -n "3.) APACHE Root "
- echo -e $APACHEROOT
- echo -e -n "4.) APACHE conf.d "
- echo -e $APACHECONF
- echo -e -n "5.) APACHE conf "
- echo -e $APACHECONFD
- echo -e -n "6.) MYSQL Databases "
- echo -e $MYSQLDATABASES
- echo -e -n "7.) SSL Configuration "
- echo -e $SSLCONFIGS
- echo -e -n "8.) SSL Default Keys "
- echo -e $SSLDEFAULTKEYS
- echo -e -n "9.) PHPMyAdmin "
- echo -e $PHPADMIN
- echo -e "10.) <- Return"
- echo ""
- read opt
- if [ "$opt" = "1" ]; then
- $TEXT $DESCRIPTIONS
- elif [ "$opt" = "2" ]; then
- $DIR $WWWROOT
- elif [ "$opt" = "3" ]; then
- $DIR $APACHEROOT
- elif [ "$opt" = "4" ]; then
- $DIR $APACHECONF
- elif [ "$opt" = "5" ]; then
- $DIR $APACHECONFD
- elif [ "$opt" = "6" ]; then
- $DIR $MYSQLDATABASES
- elif [ "$opt" = "7" ]; then
- $DIR $SSLCONFIGS
- elif [ "$opt" = "8" ]; then
- $DIR $SSLDEFAULTKEYS
- elif [ "$opt" = "9" ]; then
- $DIR $PHPADMIN
- elif [ "$opt" = "10" ]; then
- mainmenu
- fi
- echo ""
- echo -e "\E[34;3m [enter] ";
- read blank
- directorymenu
- }
- ############################################################
- function confmenu {
- clear
- echo -e "\E[34;3m:::Web Server Administration - Configurations :::" #BOLD BLUE
- echo "================================================"
- echo ""
- echo -e "\E[31;3mConfiguration Menu:" #RED
- echo -e "\E[36;2m" #Light Green
- echo -e "1.) Edit Apache Configuration (httpd.conf)"
- echo -e "2.) Edit Php Configuration (php.ini)"/home/premise/core/
- echo -e "3.) Edit SSL Apache Configuration (ssl.conf)"
- echo -e "4.) Edit PhpMyAdmin Apache Configuration (phpMyAdmin.conf)"
- echo -e "5.) Edit PhpMyAdmin Setup Configuration (config.inc.php)"
- echo -e "6.) Edit Private Interface Configuration (eth0:0)"
- echo -e "7.) Edit Public Interface Configuration (eth0:1)"
- echo -e "8.) Restart Web Services (required after any changes)"
- echo -e "9.) Restart Network Services"
- echo -e "10.) Reset Mysql and Apache Runlevel (Run on Startup)"
- echo -e "11.) Reset Security and Ownership on databases and wwwroot"
- echo -e "12.) <- Return"
- echo ""
- read opt
- if [ "$opt" = "1" ]; then
- $EDITTEXT "/etc/httpd/conf/httpd.conf"
- elif [ "$opt" = "2" ]; then
- $EDITTEXT "/etc/php.ini"
- elif [ "$opt" = "3" ]; then
- $EDITTEXT "/etc/httpd/conf.d/ssl.conf"
- elif [ "$opt" = "4" ]; then
- $EDITTEXT "/etc/httpd/conf.d/phpMyAdmin.conf"
- elif [ "$opt" = "5" ]; then
- $EDITTEXT "usr/share/phpMyAdmin/config.inc.php"
- elif [ "$opt" = "6" ]; then
- $EDITTEXT "/etc/sysconfig/network-scripts/ifcfg-eth0"
- elif [ "$opt" = "7" ]; then
- $EDITTEXT "/etc/sysconfig/network-scripts/ifcfg-eth0:1"
- elif [ "$opt" = "8" ]; then
- echo "Restarting Services ..."
- service httpd stop
- service mysqld stop
- service mysqld start
- service httpd start
- echo ""
- echo "Services restarted..."
- echo ""
- echo -e "\E[34;3m [enter] "
- echo ""
- read blank
- confmenu
- elif [ "$opt" = "9" ]; then
- service network restart
- elif [ "$opt" = "10" ]; then
- chkconfig --levels 235 mysqld on
- chkconfig --levels 235 httpd on
- chkconfig --list httpd
- chkconfig --list mysqld
- echo ""
- echo -e "\E[34;3m Levels Reset..."
- elif [ "$opt" = "11" ]; then
- echo "Resetting Permissions on WWW root in $WWWROOT"
- chown premise -R $WWWROOT
- chgrp premise -R $WWWROOT
- chmod 771 -R $WWWROOT
- echo "Resetting Permissions on Databases in $MYSQLDATABASES"
- chown premise -R $MYSQLDATABASES
- chgrp premise -R $MYSQLDATABASES
- chmod 771 -R $MYSQLDATABASES
- echo ""
- echo "Permissions Reset"
- elif [ "$opt" = "12" ]; then
- mainmenu
- fi
- echo ""
- echo -e "\E[34;3m [enter] "
- echo ""
- read blank
- confmenu
- }
- ############################################################
- function backupmenu {
- clear
- echo -e "\E[34;3m:::Web Server Administration - Backup Menu :::" #BOLD BLUE
- echo "============================================"
- echo ""
- echo -e "\E[31;3mBackup Options:" #RED
- echo -e "\E[36;2m" #Light Green
- echo "Perform Full backup of WWW Directory and Databases ... (Press Enter)"
- read blank
- echo -e "\E[31;3mBacking up to Root's Desktop ..."
- echo -e "\E[31;3mStarting SQL Structure Backup ..."
- echo -e "\E[36;2m"
- timestamp=`date +%s`
- BACKUPSOURCE=$BACKUPDIR
- BACKUPDIR="${BACKUPDIR}/backup_${timestamp}"
- mkdir $BACKUPDIR
- mysqldump --all-databases -f --skip-comments --password=r*fed*core08 --host=localhost --user=root --no-data > $BACKUPDIR/databases_structure_$timestamp.sql
- echo -e "\E[31;3mStructure Done!"
- echo ""
- echo -e "\E[31;3mStarting SQL Data backup ..."
- echo -e "\E[36;2m"
- mysqldump --all-databases -f --skip-comments --password=r*fed*core08 --host=localhost --user=root > $BACKUPDIR/databases_$timestamp.sql
- echo -e "\E[31;3mData Done!"
- echo ""
- echo "Performing MysqlHotCopy of all Databases!"
- echo ""
- echo ""
- echo "getting database list ..."
- echo ""
- echo -e "\E[36;2m"
- cd $MYSQLDATABASES
- ARRAY=`find * -type d -prune`
- cd $BACKUPDIR
- mkdir -p databases_hotcopy_$timestamp
- echo "starting backup ..."
- echo ""
- for DATABASE in `echo $ARRAY`
- do
- echo "backing up ${DATABASE}"
- mkdir databases_hotcopy_$timestamp/$DATABASE
- mysqlhotcopy --quiet --user=root --password=r*fed*core08 $DATABASE $BACKUPDIR/databases_hotcopy_$timestamp/$DATABASE
- done
- echo "mysqlhotcopy completed!"
- echo ""
- echo ""
- echo "Backing up Core Directories ..."
- currentdir=`pwd`
- cd $WWWROOT
- cd ..
- echo "Source Directory is: ${WWWROOT}"
- echo "Backup DEST Dir is: ${BACKUPDIR}"
- echo ""
- echo ""
- echo "Excluding Files larger than ${FILELIMIT} - Searching ..."
- rm -f $BACKUPROOT/exclude.txt
- find $WWWROOT -size +$FILELIMIT -fprintf $BACKUPROOT/exclude.txt '%p\n'
- echo -e "\E[32;3mDone ... Excluding these files:"
- echo ""
- cat $BACKUPROOT/exclude.txt
- echo ""
- echo "Starting Archive Creating ..."
- tar --create --recursion --verbose --exclude-from $BACKUPROOT/exclude.txt --exclude "${WWWROOT}/backup" --file=coreroot_master_$timestamp.tar $WWWROOT >> coreroot_master_$timestamp.tar.log
- echo "Moving Backup ..."
- mv -f -t $BACKUPDIR coreroot_master_$timestamp.tar coreroot_master_$timestamp.tar.log
- cd $currentdir
- FILE="coreroot_master_${timestamp}.tar"
- FILEINFO=`ls -l ${BACKUPDIR}/${FILE}`
- echo -e "\E[32;3mBackup ${FILE} Created:"
- echo -e "\E[34;3m$FILEINFO"
- echo ""
- echo "Done ..."
- echo ""
- echo "All operations completed... "
- echo -e "\E[34;3mDEST: ${BACKUPDIR} SRC: ${WWWROOT}"
- echo ""
- echo "[Enter]"
- read blank
- mainmenu
- }
- function settingsmenu {
- clear
- echo -e "\E[34;3m:::Web Server Administration - Settings Menu :::" #BOLD BLUE
- echo "================================================"
- echo ""
- echo -e "\E[31;3mDirectory Menu:" #RED
- echo -e "\E[36;2m" #Light Green
- echo -e "1.) GUI Mode (xserver is active)"
- echo -e "2.) Text Mode (command line only)"
- echo -e "3.) <- Return"
- read opt
- if [ "$opt" = "1" ]; then
- guimode
- elif [ "$opt" = "2" ]; then
- textmode
- elif [ "$opt" = "3" ]; then
- mainmenu
- fi
- }
- ############################################################
- function guimode {
- TEXT="gedit"
- EDITTEXT="gedit"
- DIR="nautilus --browser"
- echo "Graphical Mode Set ..."
- echo ""
- echo -e "\E[34;3m [enter] "
- read blank
- echo ""
- settingsmenu
- }
- function textmode {
- TEXT="cat"
- EDITTEXT="vi"
- DIR="echo"
- echo "Text Mode Set ..."
- echo ""
- echo -e "\E[34;3m [enter] "
- read blank
- echo ""
- settingsmenu
- }
- mainmenu
- su
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement