Skip to content

Instantly share code, notes, and snippets.

@gncabrera
Last active September 20, 2017 19:02
Show Gist options
  • Save gncabrera/404ae7a82ba4330e27c7c31dde71cc14 to your computer and use it in GitHub Desktop.
Save gncabrera/404ae7a82ba4330e27c7c31dde71cc14 to your computer and use it in GitHub Desktop.
#!/bin/sh
PROCESS=$1
BASE_FOLDER=$2
USER=$3
sudo systemctl stop $PROCESS
sudo -u $USER mkdir /$BASE_FOLDER/data/$PROCESS
sudo -u $USER mkdir /$BASE_FOLDER/etc/$PROCESS
sudo -u $USER mkdir /$BASE_FOLDER/code/$PROCESS
sudo -u $USER rm -r /$BASE_FOLDER/code/$PROCESS/current
cd /$BASE_FOLDER/code/$PROCESS
sudo -u $USER wget https://github.com/gncabrera/seed-java-daemon/releases/download/1.0.0/daemon-1.0.0.tar
sudo -u $USER tar -xvf /$BASE_FOLDER/code/$PROCESS/$PROCESS.tar
sudo -u $USER mv $PROCESS-1.0.0 current
sudo cp /$BASE_FOLDER/code/$PROCESS/current/systemd/$PROCESS.service /usr/local/lib/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable $PROCESS
sudo systemctl start $PROCESS
sudo systemctl status $PROCESS
#!/bin/sh
BASE_FOLDER=$1
USER=$2
sudo mkdir -p /usr/local/lib/systemd/system
# daemons user creation
echo "Creating folder $BASE_FOLDER for user $USER..."
sudo mkdir /$BASE_FOLDER
sudo useradd -d /$BASE_FOLDER $USER
sudo usermod -a -G systemd-journal $USER
sudo chown -R $USER:$USER /$BASE_FOLDER
echo "Creating daemons folders..."
sudo -u $USER mkdir /$BASE_FOLDER/code
sudo -u $USER mkdir /$BASE_FOLDER/data
sudo -u $USER mkdir /$BASE_FOLDER/etc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment