#!/bin/sh # Allow switching from one mac to another by saving stuff stored outside the /Users/ directory # v0.4 # Guillaume DURR # g.durr.removethis@free.fr # # http://www.macosxhints.com/article.php?story=20040329150916121 # # # Stuff are saved in the same this script is # If the script is executed by root, the crontab, mail DB, ... are saved for ALL users ############################### Configure ################################### # What Password to user to connect to the localhost mySQL database ? sql_password='' ################################################################################ list_all_user=`/bin/ls /Users/ | grep -v "Shared" | grep -v "^."` me=`whoami` if [ "$me" != 'root' ]; then list_user=$me inly_one_user=true else list_user=$list_all_user inly_one_user=false fi cd `dirname "$0"` mpath=`date` mkdir "$mpath" cd "$mpath" #--------------------------------- APACHE/WEB --------------------------------- mkdir http cp /etc/httpd/httpd.conf ./http cp /etc/httpd/mime.types ./http cp -R /etc/httpd/users ./http #--------------------------------- WEB SITE --------------------------------- mkdir web cp -R /Library/WebServer/ ./web #--------------------------------- GENERAL Preferences --------------------------------- cp -R /Library/Preferences/SystemConfiguration . cp /etc/ftpusers . cp /etc/hostconfig . echo $PATH > ./PATH.txt #--------------------------------- CRONTAB --------------------------------- mkdir crontab cp -R /etc/crontab ./crontab/ if [ $only_one_user == true ]; then crontab_user=`crontab -l` if [ -z "$crontab_user" ]; then echo "no crontab for $user" > ./crontab/$me else echo "$crontab_user" > ./crontab/$me fi else for user in $list_user do echo $user crontab_user=`crontab -l -u $user` if [ -z "$crontab_user" ]; then echo "no crontab for $user" > ./crontab/$user else echo "$crontab_user" > ./crontab/$user fi done fi #--------------------------------- STARTUPITEM --------------------------------- ls -lisa /Library/StartupItems/ > ./Info_startupitem.txt #--------------------------------- LOCAL MAIL DB --------------------------------- mkdir mail for user in $list_user do if [ -f /var/mail/$user ]; then cp /var/mail/$user ./mail/$user else echo "no mail DB for $user" > ./mail/$user fi done #--------------------------------- MYSQL --------------------------------- if [ -e /usr/local/mysql/bin/mysqldump ]; then if [ -z $sql_password ]; then echo "There is no default password to access the mySQL Database" echo "Next time, you can add a password by setting the 'sql_password' variable at the top of the script" echo "What password to access the mySQL Database?" read sql_password fi /usr/local/mysql/bin/mysqldump -h localhost --user=root --password="$sql_password" --all-databases > ./mysql.txt fi #--------------------------------- Liste All USers --------------------------------- echo $list_all_user > ./list_all_user.txt #--------------------------------- END ---------------------------------