Skip to content

Commit

Permalink
net-proxy/daed: add openrc init script
Browse files Browse the repository at this point in the history
Signed-off-by: irort <[email protected]>
  • Loading branch information
irort committed Nov 12, 2023
1 parent 3ef84e6 commit 2f22d4a
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 0 deletions.
16 changes: 16 additions & 0 deletions net-proxy/daed/daed-0.3.3_p1.ebuild
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,20 @@ src_install(){
keepdir /etc/daed/
dosym -r "/usr/share/v2ray/geosite.dat" /usr/share/daed/geosite.dat
dosym -r "/usr/share/v2ray/geoip.dat" /usr/share/daed/geoip.dat

# thanks to @MarksonHon
newinitd "${FILESDIR}"/${PN}.initd daed
}

pkg_postinst() {
elog
elog "For OpenRC user, if you want to use"
elog "openrc to manager daed service,"
elog "please refer to dae document to modify"
elog "rc.conf and sysfs first, then reboot."
elog "https://github.com/daeuniverse/dae/blob/main/docs/en/tutorials/run-on-alpine.md"
elog "Now you can start and add it to default runlevel "
elog "# rc-service daed start"
elog "# rc-update add daed default"
elog
}
16 changes: 16 additions & 0 deletions net-proxy/daed/daed-9999.ebuild
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,20 @@ src_install(){
keepdir /etc/daed/
dosym -r "/usr/share/v2ray/geosite.dat" /usr/share/daed/geosite.dat
dosym -r "/usr/share/v2ray/geoip.dat" /usr/share/daed/geoip.dat

# thanks to @MarksonHon
newinitd "${FILESDIR}"/${PN}.initd daed
}

pkg_postinst() {
elog
elog "For OpenRC user, if you want to use"
elog "openrc to manager daed service,"
elog "please refer to dae document to modify"
elog "rc.conf and sysfs first, then reboot."
elog "https://github.com/daeuniverse/dae/blob/main/docs/en/tutorials/run-on-alpine.md"
elog "Now you can start and add it to default runlevel "
elog "# rc-service daed start"
elog "# rc-update add daed default"
elog
}
37 changes: 37 additions & 0 deletions net-proxy/daed/files/daed.initd
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/sbin/openrc-run
# Copyright 2023 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

name="daed daemon"
description="daed Service"
command="/usr/bin/daed"
command_args="run "
pidfile="/run/${RC_SVCNAME}.pid"
command_background="yes"
output_log="/var/log/daed/access.log"
error_log="/var/log/daed/error.log"
supervisor="supervise-daemon"
rc_ulimit="-n 30000"
rc_cgroup_cleanup="yes"

depend() {
after docker net net-online sysctl
use net
}

start_pre() {
if [ -d /sys/fs/bpf ] && ! mountinfo -q /sys/fs/bpf; then
error "bpf filesystem not mounted, exiting..."
return 1
fi
if [ -d /sys/fs/cgroup ] && ! mountinfo -q /sys/fs/cgroup/; then
error "cgroup filesystem not mounted, exiting..."
return 1
fi
if [ ! -d "/tmp/daed/" ]; then
mkdir "/tmp/daed"
fi
if [ ! -L "/var/log/daed" ]; then
ln -s "/tmp/daed/" "/var/log/"
fi
}

0 comments on commit 2f22d4a

Please sign in to comment.