Skip to content

Commit

Permalink
Do not have bootstrap run sudo commands.
Browse files Browse the repository at this point in the history
Your site user may not have access to sudo, and your admin user may
cause permission issues if used to do the git checkout, or the Perl
module installation. Document the separate script to install system
packages instead.

Co-authored-by: Sam Pearson <sam@mysociety.org>
  • Loading branch information
dracos and sagepe committed Jul 15, 2020
1 parent 67823bc commit 1243e70
Show file tree
Hide file tree
Showing 10 changed files with 13 additions and 21 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -25,6 +25,7 @@
- Improve compatibility with G Suite OpenID Connect authentication. #3032
- Fix duplicate asset message after dismissing duplicate suggestions.
- Improve moderation diff display in a few small ways. #3105
- Do not have bootstrap run sudo commands. #2930
- Admin improvements:
- Display user name/email for contributed as reports. #2990
- Interface for enabling anonymous reports for certain categories. #2989
Expand Down
3 changes: 3 additions & 0 deletions Vagrantfile
Expand Up @@ -60,6 +60,9 @@ EOS
# This just runs our update script, used on our offical box.
$update = <<-EOS
chown -R vagrant:vagrant /home/vagrant/.cpanm
# Ensure any new packages are installed
/home/vagrant/fixmystreet/bin/install_packages
# Run setup script
su vagrant -c '/home/vagrant/fixmystreet/script/setup ; exit $?'
if [ $? -eq 0 ]; then
touch /tmp/success
Expand Down
1 change: 1 addition & 0 deletions bin/docker.preinit
Expand Up @@ -34,6 +34,7 @@ fi
su $FMS_DB_USER -c "${FMS_ROOT}/bin/docker-cobrand"

# Ensure things are up to date - schema, CSS, etc
${FMS_ROOT}/bin/install_packages docker
su $FMS_DB_USER -c "${FMS_ROOT}/script/update"

# Update reports
Expand Down
2 changes: 1 addition & 1 deletion bin/install_packages
Expand Up @@ -3,7 +3,7 @@ set -e

cd "$(dirname "${BASH_SOURCE[0]}")/.."

PACKAGE_FILE=conf/packages
PACKAGE_FILE=conf/packages.generic

[ -n "$1" ] && PACKAGE_FILE="conf/packages.${1}"

Expand Down
2 changes: 0 additions & 2 deletions bin/site-specific-install.sh
Expand Up @@ -54,8 +54,6 @@ fi

install_website_packages

su -l -c "touch '$DIRECTORY/admin-htpasswd'" "$UNIX_USER"

if [ $INSTALL_DB = true ]; then
add_postgresql_user
fi
Expand Down
1 change: 0 additions & 1 deletion docker-compose.yml
Expand Up @@ -30,7 +30,6 @@ services:
FMS_ROOT: '/var/www/fixmystreet/fixmystreet'
SUPERUSER_EMAIL: 'superuser@example.org'
SUPERUSER_PASSWORD: '5up3r53cr3t'
SKIP_PACKAGES_INSTALL:
networks:
default:
aliases:
Expand Down
2 changes: 1 addition & 1 deletion docs/install/manual-install.md
Expand Up @@ -40,7 +40,7 @@ dependencies are listed in `conf/packages.generic`. To install all of them you
can run e.g.:

{% highlight bash %}
$ sudo xargs -a conf/packages.generic apt-get install
$ sudo bin/install_packages
{% endhighlight %}

A similar list of packages should work for other Debian-based distributions.
Expand Down
4 changes: 3 additions & 1 deletion docs/updating/ami.md
Expand Up @@ -41,10 +41,12 @@ make sure they are all committed to your local branch and fork first, see
to try checking out your repository elsewhere and trying the merge there first,
to see if it there are any problems.

After updating the code, you should run the following command to update any
After updating the code, you should run the following commands to update any
needed dependencies and any schema changes to your database. It's a good idea
to take a backup of your database first.

admin@ip-10-58-191-98:/var/www/fixmystreet/fixmystreet$ sudo bin/install_packages

fms@ip-10-58-191-98:~/fixmystreet$ script/update

If you have made changes to the schema yourself, this may not work,
Expand Down
5 changes: 3 additions & 2 deletions docs/updating/index.md
Expand Up @@ -53,12 +53,13 @@ you are too worried to merge in case it breaks something.

## Subsequent dependency updates

After updating the code, you should run the following command to update any
After updating the code, you should run the following commands to update any
needed dependencies and any schema changes to your database. It's a good idea
to take a backup of your database first.

{% highlight bash %}
script/update
sudo bin/install_packages # (as your admin user)
script/update # (as the fms user)
{% endhighlight %}

Of course, if you have made changes to the database schema yourself, this may
Expand Down
13 changes: 0 additions & 13 deletions script/bootstrap
Expand Up @@ -4,17 +4,4 @@ set -e
cd "$(dirname "$0")/.."

git submodule --quiet update --init --recursive --rebase

if [ -z ${SKIP_PACKAGES_INSTALL:+x} ] ; then
# Let's see if we can't work out where we might be running.
if cut -d/ -f2 /proc/self/cgroup | sort -u | grep -q docker ; then
echo "==> Installing Docker packages..."
sudo bin/install_packages docker
else
# Fallback
echo "==> Installing generic packages..."
sudo bin/install_packages generic
fi
fi

bin/install_perl_modules

0 comments on commit 1243e70

Please sign in to comment.