blob: 7bef31ecfbfea45acf3f2346aede8b9401329600 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
## Basic init yt-local for openrc
1. Write `/etc/init.d/ytlocal` file.
```
#!/sbin/openrc-run
# Distributed under the terms of the GNU General Public License v3 or later
name="yt-local"
pidfile="/var/run/ytlocal.pid"
command="/usr/sbin/ytlocal"
depend() {
use net
}
start_pre() {
if [ ! -f /usr/sbin/ytlocal ] ; then
eerror "Please create script file of ytlocal in '/usr/sbin/ytlocal'"
return 1
else
return 0
fi
}
start() {
ebegin "Starting yt-local"
start-stop-daemon --start --exec "${command}" --pidfile "${pidfile}"
eend $?
}
reload() {
ebegin "Reloading ${name}"
start-stop-daemon --signal HUP --pidfile "${pidfile}"
eend $?
}
stop() {
ebegin "Stopping ${name}"
start-stop-daemon --quiet --stop --exec "${command}" --pidfile "${pidfile}"
eend $?
}
```
after, modified execute permissions:
$ doas chmod a+x /etc/init.d/ytlocal
2. Write `/usr/sbin/ytlocal` and configure path.
```
#!/usr/bin/env bash
cd /home/your-path/ytlocal/ # change me
source venv/bin/activate
python server.py > /dev/null 2>&1 &
echo $! > /var/run/ytlocal.pid
```
after, modified execute permissions:
$ doas chmod a+x /usr/sbin/ytlocal
3. OpenRC check
- status: `doas rc-service ytlocal status`
- start: `doas rc-service ytlocal start`
- restart: `doas rc-service ytlocal restart`
- stop: `doas rc-service ytlocal stop`
- enable: `doas rc-update add ytlocal default`
- disable: `doas rc-update del ytlocal`
When yt-local is run with administrator privileges,
the configuration file is stored in /root/.youtube-local
|