Skip to content

Commit

Permalink
Packaging changes:
Browse files Browse the repository at this point in the history
  * add pleaserun gem to target system.
  * install script will attempt to create a corresponding service using pleaserun.
  * mudclub-remove to be executed after package removal
  * mudclub-remove will attempt to remove the installed pleaserun service - works for systemd only.
  * simplified mudclub-start manual script
  • Loading branch information
iangullo committed Apr 19, 2023
1 parent eef5851 commit f0b9a10
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 14 deletions.
8 changes: 4 additions & 4 deletions .fpm
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
--depends git
--depends 'ruby > 3.1.0'
--depends 'ruby-rubygems > 3.2.0'
--depends 'postgresql > 12.0'
--depends 'libpq-dev > 12.0'
--depends 'nodejs > 12.0'
--depends 'postgresql > 13.0'
--depends 'libpq-dev > 13.0'
--depends 'nodejs > 16.0'
--depends 'nginx > 1.18'
--config-files src/config/mudclub
--after-install src/scripts/install.sh
--after-upgrade src/scripts/mudclub-update.sh
--before-remove src/scripts/mudclub-remove.sh
--after-remove src/scripts/mudclub-remove.sh
src/scripts/mudclub-start.sh=/usr/local/bin/mudclub-start
src/scripts/mudclub-stop.sh=/usr/local/bin/mudclub-stop
src/scripts/mudclub-update.sh=/usr/local/bin/mudclub-update
Expand Down
Binary file modified build/mudclub-server_0.1.0_all.deb
Binary file not shown.
11 changes: 7 additions & 4 deletions src/config/mudclub
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@
# Configuration file - you may modify the options here to your
# system.

# Server located in...
MUDHOME="/srv/rails/mudclub"

# Assuming this to be a production server
RAILS_ENV='production'
RAILS_ENV="production"

# Posstgresql connection parameters
DB_HOST='localhost'
DB_USERNAME='mudclub'
DB_HOST="localhost"
DB_USERNAME="mudclub"
DB_PASSWORD='EtClausi'
DB_NAME='mudclub'
DB_NAME="mudclub"
4 changes: 4 additions & 0 deletions src/scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ if mkdir -p $MUDHOME 2> /dev/null ; then
su - $MUDCLUB -c 'echo "fi" >> .bashrc'
echo "OK"
printf "* Installing necesssary gems...\n "
gem install pleaserun 2> /dev/null
su - $MUDCLUB -c "$BUNDLE config set --local path 'vendor/bundle' 2> /dev/null" 2> /dev/null
su - $MUDCLUB -c "$BUNDLE config set --local without 'development test' 2> /dev/null" 2> /dev/null
su - $MUDCLUB -c "$BUNDLE install 2> /dev/null" 2> /dev/null
Expand Down Expand Up @@ -71,6 +72,9 @@ if mkdir -p $MUDHOME 2> /dev/null ; then
# pleaserun --name $MUDCLUB --user $MUDCLUB --overwrite --description "MudClub service definition" --chdir $MUDHOME /bin/bash -lc 'rails server -e production'
echo "================================"
echo "MudClub: Successfully built!"
echo "================================"
echo "* Attempting to configure MudClub service..."
pleaserun --install --user $MUDCLUB --group $MUDCLUB --name $MUDCLUB --description "MudClub: open source team sports club management service" --chdir $MUDHOME --environment-file /etc/mudclub "/srv/rails/mudclub/bin/rails server"
exit 0
else
printf "ERROR!\n => Could not clone from https://github.com/iangullo/mudclub.git\n"
Expand Down
8 changes: 5 additions & 3 deletions src/scripts/mudclub-remove.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,17 @@ mkdir -p $SRVPATH
echo "MudClub: Removing application..."
echo "================================"
printf " * Removing $MUDCLUB fron Nginx..."
#systemctl stop $MUDCLUB.service
#systemctl disable $MUDCLUB.service
systemctl stop $MUDCLUB.service
systemctl disable $MUDCLUB.service
rm /etc/default/$MUDCLUB 2> /dev/null
rm /etc/systemd/system/$MUDCLUB.service 2> /dev/null
rm /etc/nginx/sites-enabled/mudclub 2> /dev/null
rm /etc/nginx/sites-available/mudclub 2> /dev/null
nginx -t 2> /dev/null && systemctl reload nginx 2> /dev/null
echo "OK"
cd $MUDHOME
printf " * Deleting database..."
su - $MUDCLUB -c "rails db:drop"
su - $MUDCLUB -c "rails db:drop -e production"
VAL=`su - postgres -c "psql -t -c '\du'" | cut -d \| -f 1 | grep -w $MUDCLUB`
if [ ! -z $VAL ] ; then
su - postgres -c "dropuser $MUDCLUB"
Expand Down
4 changes: 1 addition & 3 deletions src/scripts/mudclub-start.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/bin/bash
# Launch rails application for MudClub
MUDHOME=/srv/rails/mudclub
cd $MUDHOME
nohup rails server -e production &
su - mudclub -c "nohup rails server &"

0 comments on commit f0b9a10

Please sign in to comment.