forked from cambridgesu/bob-gui-deploy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
2-install-bob.sh
executable file
·52 lines (43 loc) · 2.12 KB
/
2-install-bob.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/bash
# This script is idempotent - it can be safely re-run without destroying existing data
# Installation of the voting component (BOB)
# Add the BOB software (the native voting component, without any setup management)
if [ ! -d ${installationRoot}/bob ] ; then
cd "${installationRoot}"
git clone https://github.com/camvote/bob.git
cd "${SCRIPTDIRECTORY}"
fi
# MTA (mail sending)
# Useful guides for Postfix at: http://www-uxsup.csx.cam.ac.uk/~fanf2/hermes/doc/misc/postfix.html and http://www-co.ch.cam.ac.uk/facilities/clusters/theory/heartofgold/heartofgold-postfix.html
sudo apt-get install -y postfix
if [ "${mtaRelayhost}" ] ; then
if ! grep -qF "${mtaRelayhost}" /etc/postfix/main.cf ; then
echo $'\nrelayhost = '"${mtaRelayhost}" >> /etc/postfix/main.cf
fi
fi
# The canonical config should be something like the following (uncommented) :
# wwwrun [email protected]
# @machinename @example.com
#!# Needs to check for existence of file also
if ! grep -qF "${apacheUser}" /etc/postfix/canonical ; then
echo $'\n'"${apacheUser} ${emailTech}" >> /etc/postfix/canonical
fi
if ! grep -qF "@${HOSTNAME}" /etc/postfix/canonical ; then
echo $'\n'"@${HOSTNAME} @${mailDomain}" >> /etc/postfix/canonical
fi
postmap /etc/postfix/canonical
postfix reload
#? service postfix restart
# Create the voting database
${mysql} -e "CREATE DATABASE IF NOT EXISTS ${dbDatabase} DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;"
# Create database user privileges (which will create the users if they do not exist); see: https://github.com/cusu/bob/blob/master/BOB.php#L1436
# NB Staging permission also will be created later if using the ingest module
${mysql} -e "GRANT SELECT,INSERT,UPDATE ON ${dbDatabase}.* TO '${dbUsername}'@'localhost' IDENTIFIED BY '${dbPassword}';"
${mysql} -e "GRANT SELECT,CREATE ON ${dbDatabase}.* TO '${dbSetupUsername}'@'localhost' IDENTIFIED BY '${dbPassword}';"
# Install (download) OpenSTV, the STV counting program
sudo apt-get install -y python
if [ ! -d ${installationRoot}/openstv ] ; then
cd "${installationRoot}"
git clone https://github.com/cusu/openstv.git
cd "${SCRIPTDIRECTORY}"
fi