aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xbin/install-as-user92
-rw-r--r--bin/site-specific-install.sh22
-rwxr-xr-x[-rw-r--r--]bin/update-schema7
3 files changed, 75 insertions, 46 deletions
diff --git a/bin/install-as-user b/bin/install-as-user
index 1d6cce982..0813a6b70 100755
--- a/bin/install-as-user
+++ b/bin/install-as-user
@@ -1,7 +1,10 @@
#!/bin/sh
set -e
-set -x
+error_msg() { printf "\033[31m%s\033[0m\n" "$*"; }
+notice_msg() { printf "\033[33m%s\033[0m " "$*"; }
+done_msg() { printf "\033[32m%s\033[0m\n" "$*"; }
+DONE_MSG=$(done_msg done)
if [ $# -ne 3 ]
then
@@ -14,6 +17,15 @@ fi
UNIX_USER="$1"
HOST="$2"
DIRECTORY="$3"
+
+misuse() {
+ echo The variable $1 was not defined, and it should be.
+ echo This script should not be run directly.
+ exit 1
+}
+
+[ -z "$DEVELOPMENT_INSTALL" ] && misuse DEVELOPMENT_INSTALL
+
DB_NAME="fixmystreet"
# Check that the arguments we've been passed are sensible:
@@ -22,19 +34,19 @@ IP_ADDRESS_FOR_HOST="$(dig +short $HOST)"
if [ x = x"$IP_ADDRESS_FOR_HOST" ]
then
- echo "The hostname $HOST didn't resolve to an IP address"
+ error_msg "The hostname $HOST didn't resolve to an IP address"
exit 1
fi
if ! id "$UNIX_USER" 2> /dev/null > /dev/null
then
- echo "The user '$UNIX_USER' didn't exist."
+ error_msg "The user '$UNIX_USER' didn't exist."
exit 1
fi
if [ "$(whoami)" != "$UNIX_USER" ]
then
- echo "This script should be run by the user '$UNIX_USER'."
+ error_msg "This script should be run by the user '$UNIX_USER'."
exit 1
fi
@@ -44,24 +56,23 @@ LINK_DESTINATION="$HOME/fixmystreet"
ln -sfn "$REPOSITORY" $LINK_DESTINATION
cd "$REPOSITORY"
-# Add regularly scheduled tasks to cron:
-
-TEMPORARY_CRONTAB=$(mktemp)
-
-echo crontab file is $TEMPORARY_CRONTAB
-
-cp "$REPOSITORY"/conf/crontab.example "$TEMPORARY_CRONTAB"
-
-sed -i \
- -e 's,$FMS,'"$REPOSITORY,g" \
- -e 's,$LOCK_DIR,'"$DIRECTORY,g" \
- "$TEMPORARY_CRONTAB"
-
-crontab $TEMPORARY_CRONTAB
+if [ ! "$DEVELOPMENT_INSTALL" = true ]; then
+ echo -n "Adding crontab... "
+ # Add regularly scheduled tasks to cron:
+ TEMPORARY_CRONTAB=$(mktemp)
+ echo crontab file is $TEMPORARY_CRONTAB
+ cp "$REPOSITORY"/conf/crontab.example "$TEMPORARY_CRONTAB"
+ sed -i \
+ -e 's,$FMS,'"$REPOSITORY,g" \
+ -e 's,$LOCK_DIR,'"$DIRECTORY,g" \
+ "$TEMPORARY_CRONTAB"
+ crontab $TEMPORARY_CRONTAB
+ echo $DONE_MSG
+fi
# Install the compass gem locally - it's required for generating the
# CSS:
-
+echo "Setting up CSS... "
export GEM_HOME="$DIRECTORY/gems"
mkdir -p "$GEM_HOME"
export GEM_PATH=
@@ -81,25 +92,29 @@ gem install --no-ri --no-rdoc compass
# Use compass to generate the CSS, if it doesn't seem to already
# exist:
-
if [ ! -f web/cobrands/default/base.css ]
then
bin/make_css
fi
-
-# Write sensible values into the config file:
-
-sed -r \
- -e "s,^( *FMS_DB_HOST:).*,\\1 ''," \
- -e "s,^( *FMS_DB_NAME:).*,\\1 '$DB_NAME'," \
- -e "s,^( *FMS_DB_USER:).*,\\1 '$UNIX_USER'," \
- -e "s,^( *BASE_URL:).*,\\1 'http://$HOST'," \
- -e "s,^( *EMAIL_DOMAIN:).*,\\1 '$HOST'," \
- -e "s,^( *CONTACT_EMAIL:).*,\\1 'help@$HOST'," \
- -e "s,^( *DO_NOT_REPLY_EMAIL:).*,\\1 'help@$HOST'," \
- conf/general.yml-example > conf/general.yml
+echo $DONE_MSG
+
+# Write sensible values into the config file, if it doesn't already exist
+if [ ! -f conf/general.yml ]; then
+ echo -n "Setting up default conf/general.yml file... "
+ sed -r \
+ -e "s,^( *FMS_DB_HOST:).*,\\1 ''," \
+ -e "s,^( *FMS_DB_NAME:).*,\\1 '$DB_NAME'," \
+ -e "s,^( *FMS_DB_USER:).*,\\1 '$UNIX_USER'," \
+ -e "s,^( *BASE_URL:).*,\\1 'http://$HOST'," \
+ -e "s,^( *EMAIL_DOMAIN:).*,\\1 '$HOST'," \
+ -e "s,^( *CONTACT_EMAIL:).*,\\1 'help@$HOST'," \
+ -e "s,^( *DO_NOT_REPLY_EMAIL:).*,\\1 'help@$HOST'," \
+ conf/general.yml-example > conf/general.yml
+ echo $DONE_MSG
+fi
# Create the database if it doesn't exist:
+echo -n "Setting up database... "
if ! psql -l | egrep "^ *$DB_NAME *\|" > /dev/null
then
createdb --owner "$UNIX_USER" "$DB_NAME"
@@ -107,16 +122,21 @@ then
psql -U "$UNIX_USER" "$DB_NAME" < "$REPOSITORY"/db/schema.sql
psql -U "$UNIX_USER" "$DB_NAME" < "$REPOSITORY"/db/alert_types.sql
psql -U "$UNIX_USER" "$DB_NAME" < "$REPOSITORY"/db/generate_secret.sql
+else
+ bin/cron-wrapper update-schema --commit
fi
+echo $DONE_MSG
-# Install the required Perl modules - this may take a very long time:
-
+echo "Installing required Perl modules - this may take some time"
cd "$REPOSITORY"
bin/install_perl_modules
+echo $DONE_MSG
# Generate po and mo files (these invocations taken from Kagee's script):
-
+echo "Creating locale .mo files"
bin/cron-wrapper bin/make_po FixMyStreet-EmptyHomes
bin/cron-wrapper bin/make_emptyhomes_welsh_po
-
commonlib/bin/gettext-makemo FixMyStreet
+echo $DONE_MSG
+
+bin/cron-wrapper update-all-reports
diff --git a/bin/site-specific-install.sh b/bin/site-specific-install.sh
index d3da12104..5e59052a7 100644
--- a/bin/site-specific-install.sh
+++ b/bin/site-specific-install.sh
@@ -25,25 +25,33 @@ misuse() {
[ -z "$HOST" ] && misuse HOST
[ -z "$DISTRIBUTION" ] && misuse DISTRIBUTION
[ -z "$VERSION" ] && misuse VERSION
+[ -z "$DEVELOPMENT_INSTALL" ] && misuse DEVELOPMENT_INSTALL
-install_nginx
+add_locale cy_GB
+add_locale nb_NO
+add_locale de_CH
install_postfix
-# Check out the current released version
-su -l -c "cd '$REPOSITORY' && git checkout '$VERSION'" "$UNIX_USER"
+if [ ! "$DEVELOPMENT_INSTALL" = true ]; then
+ install_nginx
+ add_website_to_nginx
+ # Check out the current released version
+ su -l -c "cd '$REPOSITORY' && git checkout '$VERSION' && git submodule update" "$UNIX_USER"
+fi
install_website_packages
su -l -c "touch '$DIRECTORY/admin-htpasswd'" "$UNIX_USER"
-add_website_to_nginx
-
add_postgresql_user
-su -l -c "$REPOSITORY/bin/install-as-user '$UNIX_USER' '$HOST' '$DIRECTORY'" "$UNIX_USER"
+export DEVELOPMENT_INSTALL
+su -c "$REPOSITORY/bin/install-as-user '$UNIX_USER' '$HOST' '$DIRECTORY'" "$UNIX_USER"
-install_sysvinit_script
+if [ ! "$DEVELOPMENT_INSTALL" = true ]; then
+ install_sysvinit_script
+fi
if [ $DEFAULT_SERVER = true ] && [ x != x$EC2_HOSTNAME ]
then
diff --git a/bin/update-schema b/bin/update-schema
index 81c9ff4ab..92868e1b6 100644..100755
--- a/bin/update-schema
+++ b/bin/update-schema
@@ -19,13 +19,14 @@ use mySociety::DBHandle qw(dbh);
use mySociety::MaPit;
mySociety::Config::set_file("$FindBin::Bin/../conf/general");
-mySociety::DBHandle::configure(
+my %args = (
Name => mySociety::Config::get('FMS_DB_NAME'),
User => mySociety::Config::get('FMS_DB_USER'),
Password => mySociety::Config::get('FMS_DB_PASS'),
- Host => mySociety::Config::get('FMS_DB_HOST', undef),
- Port => mySociety::Config::get('FMS_DB_PORT', undef)
);
+$args{Host} = mySociety::Config::get('FMS_DB_HOST', undef) if mySociety::Config::get('FMS_DB_HOST');
+$args{Port} = mySociety::Config::get('FMS_DB_PORT', undef) if mySociety::Config::get('FMS_DB_PORT');
+mySociety::DBHandle::configure( %args );
my $commit = 0;
$commit = 1 if @ARGV && $ARGV[0] eq '--commit';