6 scriptdir=$(dirname $0)
7 UTILS_PATH=$(cd $scriptdir/../../src ; pwd)
8 export PATH=$PATH:$UTILS_PATH/utils:$UTILS_PATH/bin
9 if type forge_get_config
11 database=`FUSIONFORGE_NO_PLUGINS=true forge_get_config database_name`
13 echo "$0: FATAL ERROR : COULD NOT FIND forge_get_config"
17 if [ "x$database" = "x" ]
19 echo "Forge database name not found"
22 echo "Forge database is $database"
25 echo "Stopping apache"
26 if type invoke-rc.d 2>/dev/null
28 invoke-rc.d apache2 stop
34 echo "select count(*) from users;" | su - postgres -c "psql $database" > /dev/null 2>&1
37 echo "Stopping the database"
38 if type invoke-rc.d 2>/dev/null
40 invoke-rc.d postgresql stop
42 service postgresql stop
45 echo "Waiting for database to be down..."
47 while [ $i -lt 10 ] && is_db_up ; do
48 echo "...not yet ($(date))..."
55 echo "... FAIL: database still up?"
60 echo "Starting the database"
61 if type invoke-rc.d 2>/dev/null
63 invoke-rc.d postgresql start
65 service postgresql start
68 echo "Waiting for database to be up..."
70 while [ $i -lt 10 ] && ! is_db_up ; do
71 echo "...not yet ($(date))..."
78 echo "... FAIL: database still down?"
81 echo "Dropping database $database"
82 su - postgres -c "dropdb -e $database"
86 echo "Restore database from dump file: psql -f- < /root/dump"
87 su - postgres -c "psql -f-" < /root/dump > /var/log/pg_restore.log 2>/var/log/pg_restore.err
89 # TODO: reinit the db from scratch and create the dump
90 echo "Couldn't restore the database: No /root/dump found"
94 echo "Starting apache"
95 if type invoke-rc.d 2>/dev/null
97 invoke-rc.d apache2 start
102 echo "Flushing/restarting nscd"
103 rm -f /var/cache/nscd/* || true
104 if type invoke-rc.d 2>/dev/null
106 invoke-rc.d nscd restart || true
108 service nscd restart || true