summaryrefslogtreecommitdiff
path: root/FS-Test/bin/freeside-test-start
diff options
context:
space:
mode:
authorMark Wells <mark@freeside.biz>2015-08-04 11:15:52 -0700
committerMark Wells <mark@freeside.biz>2015-08-04 11:53:17 -0700
commit82090fc595a4c7b1d03fe3d6e0039b06f0bc9ede (patch)
tree243b990aca8c033f6b85adb0ff2cd1cc46ce7a2f /FS-Test/bin/freeside-test-start
parentce1a26f5033acf26ccf0c922b2fc43cc2baa2bb9 (diff)
UI testing tool, #37340
Diffstat (limited to 'FS-Test/bin/freeside-test-start')
-rwxr-xr-xFS-Test/bin/freeside-test-start63
1 files changed, 63 insertions, 0 deletions
diff --git a/FS-Test/bin/freeside-test-start b/FS-Test/bin/freeside-test-start
new file mode 100755
index 000000000..197a84702
--- /dev/null
+++ b/FS-Test/bin/freeside-test-start
@@ -0,0 +1,63 @@
+#!/bin/bash
+
+VERSION='3.8.1'
+
+set -ae
+
+echo "Stopping services."
+sudo service freeside stop
+sudo service apache2 stop
+
+newname=freeside_`date +%Y%m%d`
+sharedir=$(perl -MFS::Test -e "print FS::Test::share_dir()")
+
+# get company_name from existing DB, strip whitespace
+# (if there is no existing DB, continue anyway)
+testdbmarker=$(sudo -u freeside \
+ psql -tc 'select value from conf where name='\'company_name''\' | \
+ sed "s/^ //" \
+ || true
+)
+
+createdb=YES
+
+if psql -l |grep -q '^ *freeside '; then
+ if [ "$testdbmarker" = "Freeside Test $VERSION" ]; then
+ createdb=NO
+ echo "Freeside test database found."
+ else
+ echo "Renaming database to $newname."
+ psql postgres -c "ALTER DATABASE freeside RENAME TO $newname"
+ fi
+fi
+
+if [ $createdb = YES ]; then
+ echo "Creating new database from stock schema."
+ createdb --owner=freeside freeside
+ sudo -u freeside psql freeside -q -f $sharedir/test.sql > /dev/null
+fi
+
+if [ -f /usr/local/etc/freeside/htpasswd ]; then
+ newhtpasswd=htpasswd_`date +%Y%m%d`
+ echo "Renaming htpasswd to $newhtpasswd."
+ sudo mv /usr/local/etc/freeside/htpasswd /usr/local/etc/freeside/$newhtpasswd
+fi
+
+echo "Installing new htpasswd."
+sudo cp $sharedir/htpasswd /usr/local/etc/freeside/htpasswd
+
+newtime=$(sudo -u freeside \
+ psql -tc 'SELECT to_timestamp(max(_date) + 86400) FROM cust_bill' \
+)
+echo "Setting clock to $newtime."
+sudo date -s "$newtime"
+
+#echo "Applying upgrades."
+#sudo -u freeside freeside-upgrade test
+# shouldn't happen automatically
+
+# start Apache on a future date when all of the invoice dates are in the past
+echo "Restarting Apache."
+sudo service apache2 start
+
+echo "Done."