Skip to content

Commit 95498f7

Browse files
committed
add openrc support
1 parent a96162d commit 95498f7

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

docs/openrc.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
This script is pretty generic and should be able to run on any OpenRC-based distribution with minimal tweaks.
2+
3+
Save the file as `code-server` in `/etc/init.d` and make it executable with `chmod +x code-server`. Put your username in line 3.
4+
5+
```bash
6+
name=$RC_SVCNAME
7+
description="$name - VS Code on a remote server"
8+
user="" # your username here
9+
homedir="/home/$user"
10+
command="/usr/bin/$name"
11+
# Just because you can do this does not mean you should. Use ~/.config/code-server/config.yaml instead
12+
#command_args="--extensions-dir $homedir/.local/share/$name/extensions --user-data-dir $homedir/.local/share/$name --disable-telemetry"
13+
command_user="$user:$user"
14+
pidfile="/run/$name/$name.pid"
15+
command_background="yes"
16+
extra_commands="report"
17+
18+
depend() {
19+
use logger dns
20+
need net
21+
}
22+
23+
start_pre() {
24+
checkpath --directory --owner $command_user --mode 0755 /run/$name /var/log/$name
25+
}
26+
27+
start() {
28+
default_start
29+
report
30+
}
31+
32+
stop() {
33+
default_stop
34+
}
35+
36+
status() {
37+
default_status
38+
report
39+
}
40+
41+
report() {
42+
# Report to the user
43+
einfo "Reading configuration from ~/.config/code-server/config.yaml"
44+
}
45+
```
46+
47+
Start on boot with default runlevel
48+
```
49+
rc-update add code-server default
50+
```
51+
52+
Start the service immediately
53+
```
54+
rc-service code-server start
55+
```

0 commit comments

Comments
 (0)