enable running multi instances while using openrc.
Package-Manager: Portage-2.3.89, Repoman-2.3.20
Signed-off-by: Yixun Lan <dlan@gentoo.org>
#!/sbin/openrc-run
-# Copyright 1999-2019 Gentoo Authors
+# Copyright 1999-2020 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
-TJ_CONFIG="/etc/trojan/config.json"
-TJ_PIDFILE="/run/trojan.pid"
-TJ_LOG="/var/log/trojan.log"
+TJ_NAME=${SVCNAME##*.}
+if [ -n "${TJ_NAME}" -a "${SVCNAME}" != "trojan" ]; then
+ TJ_PIDFILE="/run/trojan.${TJ_NAME}.pid"
+ TJ_CONFIG="/etc/trojan/${TJ_NAME}.json"
+ TJ_LOG="/var/log/trojan.${TJ_NAME}.log"
+else
+ TJ_PIDFILE="/run/trojan.pid"
+ TJ_CONFIG="/etc/trojan/config.json"
+ TJ_LOG="/var/log/trojan.log"
+fi
depend() {
need net
src_test() {
cmake_src_test -j1
}
+
+pkg_postinst() {
+ elog "Running Trojan with multi instances"
+ elog ""
+
+ elog "Prepare /etc/trojan/\${blah}.json first"
+ elog "Config with Openrc"
+ elog " ln -s /etc/init.d/trojan{,.\${blah}}"
+ elog " rc-update add trojan.\${blah} default"
+ elog ""
+ elog "Config with Systemd"
+ elog " systemctl enable trojan.\${blah}"
+ elog ""
+}
src_test() {
cmake_src_test -j1
}
+
+pkg_postinst() {
+ elog "Running Trojan with multi instances"
+ elog ""
+
+ elog "Prepare /etc/trojan/\${blah}.json first"
+ elog "Config with Openrc"
+ elog " ln -s /etc/init.d/trojan{,.\${blah}}"
+ elog " rc-update add trojan.\${blah} default"
+ elog ""
+ elog "Config with Systemd"
+ elog " systemctl enable trojan.\${blah}"
+ elog ""
+}