Skip to content

Commit

Permalink
some minor setup script formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
mpdehaan committed Nov 6, 2018
1 parent 7c04424 commit b701033
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 3 deletions.
12 changes: 12 additions & 0 deletions setup/1_prepare.sh
Expand Up @@ -4,6 +4,8 @@ source ./0_common.sh

echo "PIP=$PIP"

#---

echo "Installing core packages..."
if [ "$DISTRO" == "redhat" ]; then
# this just covers CentOS for now
Expand Down Expand Up @@ -32,27 +34,37 @@ elif [ "$DISTRO" == "MacOS" ]; then
brew install python@3 postgresql supervisor
fi

#---

if [ "$DISTRO" != "MacOS" ]; then
sudo useradd vespene
fi

#---

echo "Setting up directories..."

sudo mkdir -p /opt/vespene
sudo mkdir -p /var/spool/vespene
sudo mkdir -p /etc/vespene/settings.d/
sudo mkdir -p /var/log/vespene/

#---

echo "Cloning the project into /opt/vespene..."
rm -rf /opt/vespene/*
sudo cp -a ../* /opt/vespene

#---

echo "APP_USER=$APP_USER"
sudo chown -R $APP_USER /opt/vespene
sudo chown -R $APP_USER /var/spool/vespene
sudo chown -R $APP_USER /etc/vespene/settings.d/
sudo chown -R $APP_USER /var/log/vespene

#---

echo "Installing python packages..."
CMD="sudo $PYTHON -m pip install -r ../requirements.txt --trusted-host pypi.org --trusted-host files.pypi.org --trusted-host files.pythonhosted.org"
echo $CMD
Expand Down
9 changes: 8 additions & 1 deletion setup/2_database.sh
Expand Up @@ -9,6 +9,7 @@
source ./0_common.sh

# ---

echo "installing packages ..."
CONFIG=""
PG_PREFIX=""
Expand All @@ -33,6 +34,7 @@ elif [[ "$DISTRO" == "MacOS" ]]; then
fi

# ---

echo "initializing the database server..."

if [[ "$DISTRO" == "archlinux" ]]; then
Expand All @@ -48,6 +50,7 @@ else
fi

# ----

echo "configuring security at ${CONFIG} ..."

# configure PostgreSQL security to allow the postgres account in locally, and allow
Expand All @@ -61,15 +64,17 @@ END_OF_CONF

sudo chown $DB_USER $CONFIG

# ---

if [ "$DISTRO" == "redhat" ]; then
echo "creating symbolic links to libraries..."
sudo ln -s /opt/rh/rh-postgresql10/root/usr/lib64/libpq.so.rh-postgresql10-5 /usr/lib64/libpq.so.rh-postgresql10-5
sudo ln -s /opt/rh/rh-postgresql10/root/usr/lib64/libpq.so.rh-postgresql10-5 /usr/lib/libpq.so.rh-postgresql10-5
fi

# ---
echo "starting postgresql..."

echo "starting postgresql..."
if [ "$OSTYPE" == "linux-gnu" ]; then
if [ "$DISTRO" == "redhat" ]; then
# run from software collections
Expand All @@ -83,6 +88,7 @@ elif [ "$DISTRO" == "MacOS" ]; then
fi

# --

echo "creating the vespene database and user..."
echo " (if you any errors from 'cd' here or further down they can be ignored)"

Expand All @@ -96,6 +102,7 @@ else
fi

# --

echo "granting access..."
# give the user access and set their password
$POST_SUDO ${PG_PREFIX}psql -d vespene -c "GRANT ALL on DATABASE vespene TO vespene"
Expand Down
11 changes: 11 additions & 0 deletions setup/3_application.sh
Expand Up @@ -12,10 +12,14 @@
# load common settings
source ./0_common.sh

#---

cd /opt/vespene
echo $PYTHON
sudo $PYTHON manage.py generate_secret

#---

# application database config
sudo tee /etc/vespene/settings.d/database.py >/dev/null <<END_OF_DATABASES
DATABASES = {
Expand All @@ -30,6 +34,7 @@ DATABASES = {
}
END_OF_DATABASES

#---

# worker configuration settings
sudo tee /etc/vespene/settings.d/workers.py >/dev/null << END_OF_WORKERS
Expand All @@ -39,14 +44,20 @@ BUILD_ROOT="${BUILDROOT}"
# FILESERVING_HOSTNAME = "this-server.example.com"
END_OF_WORKERS

#---

# ui settings
sudo tee /etc/vespene/settings.d/interface.py >/dev/null << END_OF_INTERFACE
BUILDROOT_WEB_LINK="${BUILDROOT_WEB_LINK}"
END_OF_INTERFACE

#---

# ensure app user can read all of this
echo sudo chown -R $APP_USER /etc/vespene

#---

# apply database tables
# this only has to be run once but won't hurt anything by doing
# it more than once. You also need this step during upgrades.
Expand Down
2 changes: 2 additions & 0 deletions setup/4_superuser.sh
Expand Up @@ -11,5 +11,7 @@ source ./0_common.sh
# run the django management command (this is interactive)
cd /opt/vespene

#---

echo $APP_SUDO
$APP_SUDO $PYTHON manage.py createsuperuser
2 changes: 2 additions & 0 deletions setup/5_tutorial.sh
Expand Up @@ -11,6 +11,8 @@
# load common settings
source ./0_common.sh

#---

# run the custom management command that creates the objects
cd /opt/vespene
$APP_SUDO $PYTHON manage.py tutorial_setup
Expand Down
7 changes: 5 additions & 2 deletions setup/6_services.sh
Expand Up @@ -15,6 +15,7 @@
source ./0_common.sh

# ---

# generate the supervisor configuration

echo "generating supervisor config..."
Expand All @@ -24,6 +25,7 @@ echo "creating init script..."
sudo chown -R $APP_USER /etc/vespene/

# --

# bail if on a Mac
if [ "$DISTRO" == "MacOS" ]; then
echo "launch supervisor with: supervisord -n c /etc/vespene/supervisord.conf"
Expand All @@ -32,6 +34,7 @@ fi


# ---

# generate systemd init script

sudo tee /etc/systemd/system/vespene.service >/dev/null <<END_OF_SYSTEMD
Expand All @@ -53,10 +56,10 @@ User=${APP_USER}
WantedBy=multi-user.target
END_OF_SYSTEMD

#---

echo "starting the service..."
# start the service
sudo systemctl daemon-reload
sudo systemctl start vespene.service
sudo systemctl enable vespene.service

echo "Vespene is now running on port 8000"

0 comments on commit b701033

Please sign in to comment.