Skip to content

Commit

Permalink
Merge pull request #7 from stevebrownlee/bugfix/ubuntu_installs
Browse files Browse the repository at this point in the history
Fixing bash script
  • Loading branch information
gregkorte authored Apr 11, 2024
2 parents e8a3827 + eca81e1 commit 538f1ec
Showing 1 changed file with 10 additions and 17 deletions.
27 changes: 10 additions & 17 deletions setup_ubuntu_local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

set +o histexpand
set -eu

source .env
#####
# Install required software
#####
Expand All @@ -14,13 +14,12 @@ if ! command -v psql &>/dev/null; then
sudo apt install postgresql postgresql-contrib -y
fi

echo "Checking if systemd is enabled"
SYSTEMD_PID=$(pidof systemd)

echo "Restarting Postgresql"
if [ "${SYSTEMD_PID}" == "" ]; then
if [ -d /run/systemd/system ]; then
echo "Systemd is enabled"
sudo systemctl start postgresql >> /dev/null
else
echo "Systemd is not enabled"
sudo service postgresql start >> /dev/null
fi

Expand Down Expand Up @@ -109,14 +108,7 @@ else
fi


# Check if Pipenv is installed
if ! command -v pipenv &>/dev/null; then
echo "Pipenv not found. Installing Pipenv..."
pip3 install pipenv
echo "Pipenv installation complete."
else
echo "Pipenv is already installed."
fi
pip3 install pipenv


#####
Expand All @@ -125,7 +117,7 @@ fi
export DJANGO_SETTINGS_MODULE="LearningPlatform.settings"
echo "Creating socialaccount fixture"

sudo tee $API_HOME/LearningAPI/fixtures/socialaccount.json <<EOF
sudo tee ./LearningAPI/fixtures/socialaccount.json <<EOF
[
{
"model": "sites.site",
Expand Down Expand Up @@ -153,9 +145,9 @@ sudo tee $API_HOME/LearningAPI/fixtures/socialaccount.json <<EOF
EOF

echo "Generating Django password"
DJANGO_GENERATED_PASSWORD=$(python3 ./djangopass.py "$SUPERPASS" >&1)
DJANGO_GENERATED_PASSWORD=$(python3 ./djangopass.py "$LEARN_OPS_SUPERUSER_PASSWORD" >&1)

sudo tee $API_HOME/LearningAPI/fixtures/superuser.json <<EOF
sudo tee ./LearningAPI/fixtures/superuser.json <<EOF
[
{
"model": "auth.user",
Expand All @@ -164,7 +156,7 @@ sudo tee $API_HOME/LearningAPI/fixtures/superuser.json <<EOF
"password": "$DJANGO_GENERATED_PASSWORD",
"last_login": null,
"is_superuser": true,
"username": "$SUPERUSER",
"username": "$LEARN_OPS_SUPERUSER_NAME",
"first_name": "Admina",
"last_name": "Straytor",
"email": "[email protected]",
Expand All @@ -184,6 +176,7 @@ EOF
#####
# Install project requirements and run migrations
#####
pipenv --python 3.9.1
pipenv install
pipenv run migrate

Expand Down

0 comments on commit 538f1ec

Please sign in to comment.