#!/bin/bash clear echo echo "Welcome to the MyWebSFTP Appliance setup tool." echo echo "This Script will help you to configure the MyWebSFTP Appliance." echo "It will begin by changing passwords for the following accounts and" echo "then direct you to the web interface for configuring the appliance." echo "If you have troubles with this script or are unsure of its effects," echo "please do not run it. Feel free to contact me (Anoop Bhat) at " echo "mywebsftp@gmail.com" echo echo "Cheers." echo "" # declare some variables PASS="" CONFIRMPASS="" OPENSSL="/usr/bin/openssl passwd" USERMOD="/usr/sbin/usermod -p" MYSQLADMIN="/usr/bin/mysqladmin" SQLCONNECTINFO="/etc/mywebsftp/sqlconnectinfo.conf" # error vars proerr=0 rooterr=0 echo "WARNING!" echo "=======================================================================================" echo "This script changes the passwords on System and MySQL accounts required for MyWebSFTP." echo "It does NOT change the passwords for the adminsu account in the web application." echo "If you don't want to continue, type 'n'." echo "" echo -n "Shall we begin? [y/n] " read BEGIN if [ $BEGIN != "y" ]; then echo "Exiting Script. Use y or n only." exit 0 fi getPassword() { echo -n "Please enter password: " stty -echo read PASS stty echo echo "" echo -n "Please confirm password: " stty -echo read CONFIRMPASS stty echo echo "" while [ "$PASS" != "$CONFIRMPASS" ] do echo "Passwords provided do not match. Try again." echo -n "Please enter password: " stty -echo read PASS stty echo echo "" echo -n "Please confirm password: " stty -echo read CONFIRMPASS stty echo echo "" done } echo "" echo -n "Ok! Lets see who you are: " WHOAMI=`whoami` if [ $WHOAMI != "root" ]; then echo "$WHOAMI. This script must run as root. Exiting" exit 0 else echo "$WHOAMI. Good." fi echo "" echo "Lets change the password for the Local System Accounts" echo "" echo "Changing for username: admin"; getPassword PWORD=`$OPENSSL $PASS` $USERMOD $PWORD admin if [ "$?" -ne "0" ]; then echo -e "\aAn ERROR Occurred. Aborting Script. Please change password system user 'admin' using the passwd command." exit 0 else echo "Password change was successful for user: admin." fi echo "" echo "Changing for username: root"; getPassword PWORD=`$OPENSSL $PASS` $USERMOD $PWORD root if [ "$?" -ne "0" ]; then echo -e "\aAn ERROR Occurred. Aborting Script. Please change password system user 'admin' using the passwd command.\a" exit 0 else echo "Password change was successful for user: root." fi echo "" echo "Now, lets change the passwords for the MySQL Accounts" echo "" echo "Changing for MySQL user: root"; getPassword if [ -e ~/root-mysql ]; then echo "Found ~/root-mysql file. Using that file for root mysql password." $MYSQLADMIN -u root --password=`cat ~/root-mysql` password "$PASS" else echo "File ~/root-mysql not found. Please enter the MySQL root password to change it." $MYSQLADMIN -u root -p password "$PASS" fi if [ "$?" -ne "0" ]; then rooterr=1 echo "" echo -e "\aAn ERROR Occurred. It seems that the MySQL password for user 'root' could not be changed." echo "Have you already changed the password? If so, please continue. If not, please use 'mysqladmin' to change the password." else echo "" echo "Password change was successful for MySQL user: root." fi echo "" echo "Changing for MySQL user: proftpd"; echo "Note: this step also modifies the config file for proftpd with this password." getPassword echo "Using default proftpd user account password to change password. If this doesn't work, you'll have to change the password for the proftpd account manually and update /etc/mywebsftp/sqlconnectinfo.conf" $MYSQLADMIN -u proftpd --password=3nterpris3 password "$PASS" if [ "$?" -ne "0" ]; then proerr=1 echo "" echo -e "\aAn ERROR Occurred. It seems that the MySQL password for user 'proftpd' could not be changed." echo "Have you already changed the password? If so, please continue. If not, please use 'mysqladmin' to change the password." else echo "Password change was successful for MySQL user: proftpd." echo "Updating proftpd config file." # SQLConnectInfo filexfer@localhost proftpd 3nterpris3 # DO NOT CHANGE ANYTHING AFTER THIS LINE echo "SQLConnectInfo filexfer@localhost proftpd $PASS" > $SQLCONNECTINFO echo "#DO NOT CHANGE OR ANYTHING IN THIS FILE" >> $SQLCONNECTINFO echo "Please remember to restart proftpd by executing command 'service proftpd restart'." fi echo "" echo "SCRIPT COMPLETE!" echo "" echo "ERRORS:" echo "=======" if [ "$rooterr" -eq 1 ]; then echo "It looks like the password for the MySQL account 'root' could not be changed." echo "To change it, you must have the existing root password for MySQL." echo "You can change it by executing this command." echo -e "\t$MYSQLADMIN -u root -p password \"NEW_PASSWORD\"" echo "" fi if [ "$proerr" -eq 1 ]; then echo "It looks like the password for the MySQL account 'proftpd' could not be changed." echo "To change it, you must have the existing proftpd password or the root password for MySQL." echo "You can change it by executing this command." echo -e "\t$MYSQLADMIN -u root -p password \"NEW_PASSWORD\"" echo "or" echo -e "\t$MYSQLADMIN -u proftpd -p password \"NEW_PASSWORD\"" fi if [ "$rooterr" -eq 0 ] && [ "$proerror" -eq 0 ]; then echo "No Errors." fi echo "" echo "FINAL SETUP NOTES. TO DO:" echo "==========================" echo "The script has run and any errors have been listed above." echo "To complete setup, please visit http:///install.php with the following credentials." echo "URL: http:///install.php" echo "Username: admin" echo "Password: enterprise" echo "Note: This is only for the initial configuration of the MyWebSFTP interface." echo "" echo "" echo "After you have performed the initial configuration of MyWebSFTP at the URL given above," echo "you may login to the web interface using the following credentials." echo "Username: adminsu" echo "Password: enterprise" echo "Once you have logged in, please change the account password on the interface IMMEDIATELY!" echo "" echo "You will then have a completely setup MyWebSFTP appliance. Please be sure to read the manuals." echo "" echo "If you have any errors with this script, please send an email to mywebsftp@gmail.com with the errors." echo "" echo "" echo "Cheers." echo "Anoop Bhat"