Initial commit

This commit is contained in:
Alexandre CATTEAU 2022-08-19 13:11:27 +02:00
commit 818ce0fd32
5 changed files with 63 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
variables.conf
.disabled

11
README.md Normal file
View File

@ -0,0 +1,11 @@
# WebSSH service unit
This is just a Systemd service unit for [WebSSH](https://github.com/huashengdun/webssh) web app.
### Files
* `webssh.service` is a Systemd units template for WebSSH.
#### Installation
* `install.sh` script copies the Systemd template to its destination, with the correct path (set in `variables.conf`).
### TODO
* RAS

33
install.sh Executable file
View File

@ -0,0 +1,33 @@
#!/usr/bin/env bash
run_directory=$(dirname "$0")
user=$(whoami)
source "$run_directory/variables.conf"
if [ -f $run_directory/.disabled ]; then
echo "Installation is disabled. Exiting..."
exit 0
fi
echo "Copying WebSSH unit to system directory..."
if [[ $user != 'root' ]]; then
sudo cp webssh.service /etc/systemd/system/
sudo sed -i -e "s:PH_WEBSSH_PATH:$webssh_part:g" /etc/systemd/system/webssh.service
sudo sed -i -e "s:PH_ADDR:$address:g" /etc/systemd/system/webssh.service
sudo sed -i -e "s:PH_PORT:$port:g" /etc/systemd/system/webssh.service
else
cp webssh.service /etc/systemd/system/
sed -i -e "s:PH_WEBSSH_PATH:$webssh_part:g" /etc/systemd/system/webssh.service
sed -i -e "s:PH_ADDR:$address:g" /etc/systemd/system/webssh.service
sed -i -e "s:PH_PORT:$port:g" /etc/systemd/system/webssh.service
fi
echo "Reloading Systemd..."
if [[ $user != 'root' ]]; then
sudo systemctl daemon-reload
else
systemctl daemon-reload
fi
echo "Finished install. Exiting..."
exit 0

7
variables.conf.template Normal file
View File

@ -0,0 +1,7 @@
#!/usr/bin/env bash
# Copy this file as variables.conf, with the correct values
webssh_path=
address=127.0.0.1
port=8000

10
webssh.service Normal file
View File

@ -0,0 +1,10 @@
[Unit]
Description=Run Python webssh web app
After=network.target
[Service]
User=www-data
ExecStart=/usr/bin/python3 PH_WEBSSH_PATH --address='PH_ADDR' --port=PH_PORT
[Install]
WantedBy=default.target