add systemd and OpenRC init scripts
This commit is contained in:
parent
dceb67b0aa
commit
e772bcf6d5
46
README.md
46
README.md
|
@ -20,7 +20,12 @@ This is a HP ePrint clone that has similar functions to normal HP ePrint but its
|
||||||
|
|
||||||
3. Build the binary:
|
3. Build the binary:
|
||||||
```
|
```
|
||||||
go build -o web-hp-eprint
|
go build -o eprintclone
|
||||||
|
```
|
||||||
|
|
||||||
|
4. Execture the binary:
|
||||||
|
```
|
||||||
|
./eprintclone
|
||||||
```
|
```
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
@ -31,6 +36,45 @@ In the .env file this is the only thing you can set
|
||||||
PORT=8080
|
PORT=8080
|
||||||
LOG=log # enables file logging (aka copies file to user home directory under the folder imagelog so make a folder first in the home root if you wish to enable it), to disable it replace it with nolog
|
LOG=log # enables file logging (aka copies file to user home directory under the folder imagelog so make a folder first in the home root if you wish to enable it), to disable it replace it with nolog
|
||||||
```
|
```
|
||||||
|
## Autostart with systemd or OpenRC
|
||||||
|
|
||||||
|
You can autostart the web server using systemd or OpenRC (init scripts are in the init-scripts folder)
|
||||||
|
To use it, edit the script accordingly (edit username on what user it is going to run and the path to the binary on where it will run from)
|
||||||
|
|
||||||
|
## for systemd edit the following lines:
|
||||||
|
|
||||||
|
```
|
||||||
|
; Don't forget to change the value here!
|
||||||
|
; There is no reason to run this program as root, just use your username
|
||||||
|
User=examplename # change this to your username
|
||||||
|
|
||||||
|
WorkingDirectory=/path/to/binary # change this to the path where the binary resides
|
||||||
|
```
|
||||||
|
### and to add it as a service:
|
||||||
|
|
||||||
|
```
|
||||||
|
sudo cp /path/to/cloned/repo/init-scripts/eprint-clone-web.service /etc/systemd/system
|
||||||
|
sudo systemctl daemon-reload
|
||||||
|
sudo systemctl enable eprint-clone-web.service
|
||||||
|
sudo systemctl start eprint-clone-web.service
|
||||||
|
```
|
||||||
|
|
||||||
|
## for OpenRC edit the following lines:
|
||||||
|
|
||||||
|
```
|
||||||
|
command="bash -c cd ~/web-hp-eprint-clone && ./eprintclone" # if you have put the eprintclone binary somewhere else change this line
|
||||||
|
# Don't forget to change the value here!
|
||||||
|
# There is no reason to run this program as root, just use your username
|
||||||
|
command_user="userexample" # change this to your usernames
|
||||||
|
```
|
||||||
|
|
||||||
|
### and to add it as a service:
|
||||||
|
|
||||||
|
```
|
||||||
|
sudo cp /path/to/cloned/repo/init-scripts/eprint-clone-web /etc/init.d/eprint-clone-web
|
||||||
|
sudo rc-update add eprint-clone-web
|
||||||
|
sudo rc-service eprint-clone-web start
|
||||||
|
```
|
||||||
|
|
||||||
### For this to even work
|
### For this to even work
|
||||||
You need a linux distro which has the modern equifelent of the lpr program. To check if you have the newer version, type `man lpr` and look at the program description, if it says `lpr - print files` (present on recent Ubuntu versions and rolling release distros like Arch Linux) then you are good to go otherwaise if it says `lpr - off line print` (present on Debian and older Ubuntu versions) then this won't work as the commands for the older version are different and this targets the newer version of the program.
|
You need a linux distro which has the modern equifelent of the lpr program. To check if you have the newer version, type `man lpr` and look at the program description, if it says `lpr - print files` (present on recent Ubuntu versions and rolling release distros like Arch Linux) then you are good to go otherwaise if it says `lpr - off line print` (present on Debian and older Ubuntu versions) then this won't work as the commands for the older version are different and this targets the newer version of the program.
|
||||||
|
|
15
init-scripts/eprint-clone-web
Normal file
15
init-scripts/eprint-clone-web
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
#!/sbin/openrc-run
|
||||||
|
|
||||||
|
name=eprint-clone-web
|
||||||
|
description="HP ePrint clone (on the web)"
|
||||||
|
|
||||||
|
command="bash -c cd ~/web-hp-eprint-clone && ./eprintclone" # if you have put the eprintclone binary somewhere else change this line
|
||||||
|
# Don't forget to change the value here!
|
||||||
|
# There is no reason to run this program as root, just use your username
|
||||||
|
command_user="userexample" # change this to your username
|
||||||
|
|
||||||
|
pidfile="/run/${RC_SVCNAME}.pid"
|
||||||
|
|
||||||
|
depend() {
|
||||||
|
need net
|
||||||
|
}
|
29
init-scripts/eprint-clone-web.service
Executable file
29
init-scripts/eprint-clone-web.service
Executable file
|
@ -0,0 +1,29 @@
|
||||||
|
[Unit]
|
||||||
|
Description=HP ePrint clone (on the web)
|
||||||
|
Requires=network-online.target
|
||||||
|
After=network-online.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=simple
|
||||||
|
|
||||||
|
; Don't forget to change the value here!
|
||||||
|
; There is no reason to run this program as root, just use your username
|
||||||
|
User=examplename # change this to your username
|
||||||
|
|
||||||
|
WorkingDirectory=/path/to/binary # change this to the path where the binary resides
|
||||||
|
|
||||||
|
ExecStart=./eprintclone
|
||||||
|
|
||||||
|
; Always restart the script
|
||||||
|
Restart=always
|
||||||
|
|
||||||
|
; cf. https://www.darkcoding.net/software/the-joy-of-systemd/
|
||||||
|
; /usr, /boot and /etc are read-only
|
||||||
|
ProtectSystem=full
|
||||||
|
; /tmp is isolated from all other processes
|
||||||
|
PrivateTmp=false
|
||||||
|
; Don't allow process to raise privileges (e.g. disable suid)
|
||||||
|
NoNewPrivileges=true
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
Loading…
Reference in New Issue
Block a user