From 41bc6ca4443d625eba4c3720db8234a1b2c4e18c Mon Sep 17 00:00:00 2001 From: "G.Ambatte" Date: Sun, 19 Dec 2021 18:50:35 +1300 Subject: [PATCH] Add HB service file Update install.sh to create service and set to start automatically --- .../etc/systemd/system/homebrewery.service | 13 ++++++++++ install/ubuntu/install.sh | 26 ++++++++++++++++--- 2 files changed, 35 insertions(+), 4 deletions(-) create mode 100644 install/ubuntu/etc/systemd/system/homebrewery.service diff --git a/install/ubuntu/etc/systemd/system/homebrewery.service b/install/ubuntu/etc/systemd/system/homebrewery.service new file mode 100644 index 000000000..939d11fb8 --- /dev/null +++ b/install/ubuntu/etc/systemd/system/homebrewery.service @@ -0,0 +1,13 @@ +[Unit] +Description=Homebrewery Web Server + +[Service] +User=root +After=mongodb +Environment=NODE_ENV=local +WorkingDirectory=/usr/local/homebrewery +ExecStart=node server.js +Restart=always + +[Install] +WantedBy=multi-user.target \ No newline at end of file diff --git a/install/ubuntu/install.sh b/install/ubuntu/install.sh index 4fa821102..ebad7f3f2 100644 --- a/install/ubuntu/install.sh +++ b/install/ubuntu/install.sh @@ -1,16 +1,34 @@ #!/bin/sh +# Install CURL and add required NodeJS source to package repo +echo ::Install CURL apt install -y curl +echo ::Add NodeJS source to package repo curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bash - +# Install required packages +echo ::Install Homebrewery requirements apt satisfy -y git nodejs npm mongodb -NODE_ENV=local -export NODE_ENV - +# Clone Homebrewery repo +echo ::Get Homebrewery files +cd /usr/local/ git clone https://github.com/naturalcrit/homebrewery.git +# Install Homebrewery +echo ::Install Homebrewery cd homebrewery npm install npm audit fix -npm run postinstall \ No newline at end of file +npm run postinstall + +# Create Homebrewery service +echo ::Create Homebrewery service +ln -s /usr/local/homebrewery/install/ubuntu/etc/systemd/system/homebrewery.service /etc/systemd/system/homebrewery.service +systemctl daemon-reload +echo ::Set Homebrewery to start automatically +systemctl enable homebrewery + +# Start Homebrewery +echo ::Start Homebrewery +systemctl start homebrewery \ No newline at end of file