Initial commit
This commit is contained in:
commit
818ce0fd32
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
variables.conf
|
||||
.disabled
|
11
README.md
Normal file
11
README.md
Normal 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
33
install.sh
Executable 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
7
variables.conf.template
Normal 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
10
webssh.service
Normal 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
|
Loading…
Reference in New Issue
Block a user