summaryrefslogtreecommitdiff
path: root/net-irc/znc/files
diff options
context:
space:
mode:
authorV3n3RiX <venerix@redcorelinux.org>2017-10-09 18:53:29 +0100
committerV3n3RiX <venerix@redcorelinux.org>2017-10-09 18:53:29 +0100
commit4f2d7949f03e1c198bc888f2d05f421d35c57e21 (patch)
treeba5f07bf3f9d22d82e54a462313f5d244036c768 /net-irc/znc/files
reinit the tree, so we can have metadata
Diffstat (limited to 'net-irc/znc/files')
-rw-r--r--net-irc/znc/files/README.gentoo22
-rw-r--r--net-irc/znc/files/README.gentoo-r115
-rw-r--r--net-irc/znc/files/znc-1.0-systemwideconfig.patch147
-rw-r--r--net-irc/znc/files/znc-1.6.1-create-pidfile-per-default.patch23
-rw-r--r--net-irc/znc/files/znc-1.6.1-systemwideconfig.patch215
-rw-r--r--net-irc/znc/files/znc.confd7
-rw-r--r--net-irc/znc/files/znc.confd-r124
-rw-r--r--net-irc/znc/files/znc.initd38
-rw-r--r--net-irc/znc/files/znc.initd-r139
-rw-r--r--net-irc/znc/files/znc.initd-r240
10 files changed, 570 insertions, 0 deletions
diff --git a/net-irc/znc/files/README.gentoo b/net-irc/znc/files/README.gentoo
new file mode 100644
index 000000000000..5b222a24f589
--- /dev/null
+++ b/net-irc/znc/files/README.gentoo
@@ -0,0 +1,22 @@
+To run znc as a user, run 'znc --makeconf' to create a configuration file.
+
+If znc was compiled with the 'daemon' use flag, you may run
+ emerge --config znc
+to configure it.
+
+To generate a new SSL certificate, run:
+ znc --system-wide-config-as znc --makepem -d /var/lib/znc
+as root.
+
+If migrating from a user-based install, you can copy the existing
+configuration files:
+ mkdir /var/lib/znc
+ mv /home/$USER/.znc/* /var/lib/znc
+ rm -rf /home/$USER/.znc
+ chown -R znc:znc /var/lib/znc
+You may also adjust the location of the files and the user running znc
+in /etc/conf.d/znc instead.
+
+To run as a daemon, please make sure that your configuration contains
+ PidFile = /run/znc/znc.pid
+or that the PidFile value matches the one in /etc/conf.d/znc.
diff --git a/net-irc/znc/files/README.gentoo-r1 b/net-irc/znc/files/README.gentoo-r1
new file mode 100644
index 000000000000..cbd565d3d964
--- /dev/null
+++ b/net-irc/znc/files/README.gentoo-r1
@@ -0,0 +1,15 @@
+To run znc as a user, run 'znc --makeconf' to create a configuration file.
+
+To configure the system-wide daemon, you may run 'emerge --config znc'.
+
+If migrating from a user-based install, you can copy the existing
+configuration files:
+
+ # mkdir /var/lib/znc
+ # mv /home/$USER/.znc/* /var/lib/znc
+ # rm -rf /home/$USER/.znc
+ # chown -R znc:znc /var/lib/znc
+
+OpenRC user may also adjust the location of the files and the user running
+znc in /etc/conf.d/znc instead. Systemd user may have to overwrite
+existing unit file.
diff --git a/net-irc/znc/files/znc-1.0-systemwideconfig.patch b/net-irc/znc/files/znc-1.0-systemwideconfig.patch
new file mode 100644
index 000000000000..336163dd6a0c
--- /dev/null
+++ b/net-irc/znc/files/znc-1.0-systemwideconfig.patch
@@ -0,0 +1,147 @@
+diff --git a/include/znc/znc.h b/include/znc/znc.h
+index 03be646..f493c83 100644
+--- a/include/znc/znc.h
++++ b/include/znc/znc.h
+@@ -169,6 +169,8 @@ public:
+
+ static void DumpConfig(const CConfig* Config);
+
++ void SetSystemWideConfig(bool systemWideConfig);
++
+ private:
+ CFile* InitPidFile();
+ bool DoRehash(CString& sError);
+@@ -209,6 +211,7 @@ protected:
+ unsigned int m_uiConnectPaused;
+ TCacheMap<CString> m_sConnectThrottle;
+ bool m_bProtectWebSessions;
++ bool m_bSystemWideConfig;
+ };
+
+ #endif // !_ZNC_H
+diff --git a/src/main.cpp b/src/main.cpp
+index a1f3904..4950911 100644
+--- a/src/main.cpp
++++ b/src/main.cpp
+@@ -10,6 +10,9 @@
+ #include <znc/FileUtils.h>
+ #include <sys/wait.h>
+ #include <signal.h>
++#include <sys/types.h>
++#include <pwd.h>
++#include <grp.h>
+
+ using std::cout;
+ using std::endl;
+@@ -46,6 +49,7 @@ static const struct option g_LongOpts[] = {
+ { "makepass", no_argument, 0, 's' },
+ { "makepem", no_argument, 0, 'p' },
+ { "datadir", required_argument, 0, 'd' },
++ { "system-wide-config-as", required_argument, 0, 'S' },
+ { 0, 0, 0, 0 }
+ };
+
+@@ -127,6 +131,8 @@ int main(int argc, char** argv) {
+ bool bMakeConf = false;
+ bool bMakePass = false;
+ bool bAllowRoot = false;
++ bool bSystemWideConfig = false;
++ CString sSystemWideConfigUser = "znc";
+ bool bForeground = false;
+ #ifdef ALWAYS_RUN_IN_FOREGROUND
+ bForeground = true;
+@@ -135,7 +141,7 @@ int main(int argc, char** argv) {
+ bool bMakePem = false;
+ #endif
+
+- while ((iArg = getopt_long(argc, argv, "hvnrcspd:Df", g_LongOpts, &iOptIndex)) != -1) {
++ while ((iArg = getopt_long(argc, argv, "hvnrcspd:DfS:", g_LongOpts, &iOptIndex)) != -1) {
+ switch (iArg) {
+ case 'h':
+ GenerateHelp(argv[0]);
+@@ -153,6 +159,10 @@ int main(int argc, char** argv) {
+ case 'c':
+ bMakeConf = true;
+ break;
++ case 'S':
++ bSystemWideConfig = true;
++ sSystemWideConfigUser = optarg;
++ break;
+ case 's':
+ bMakePass = true;
+ break;
+@@ -187,8 +197,36 @@ int main(int argc, char** argv) {
+ return 1;
+ }
+
++ if (bSystemWideConfig && getuid() == 0) {
++ struct passwd *pwd;
++
++ pwd = getpwnam(sSystemWideConfigUser.c_str());
++ if (pwd == NULL) {
++ CUtils::PrintError("Daemon user not found.");
++ return 1;
++ }
++
++ if ((long) pwd->pw_uid == 0) {
++ CUtils::PrintError("Please define a daemon user other than root.");
++ return 1;
++ }
++ if (setgroups(0, NULL) != 0) {
++ CUtils::PrintError("setgroups: Unable to clear supplementary group IDs");
++ return 1;
++ }
++ if (setgid((long) pwd->pw_gid) != 0) {
++ CUtils::PrintError("setgid: Unable to drop group privileges");
++ return 1;
++ }
++ if (setuid((long) pwd->pw_uid) != 0) {
++ CUtils::PrintError("setuid: Unable to drop user privileges");
++ return 1;
++ }
++ }
++
+ CZNC* pZNC = &CZNC::Get();
+ pZNC->InitDirs(((argc) ? argv[0] : ""), sDataDir);
++ pZNC->SetSystemWideConfig(bSystemWideConfig);
+
+ #ifdef HAVE_LIBSSL
+ if (bMakePem) {
+@@ -229,7 +267,7 @@ int main(int argc, char** argv) {
+ CUtils::PrintStatus(true, "");
+ }
+
+- if (isRoot()) {
++ if (isRoot() && !bSystemWideConfig) {
+ CUtils::PrintError("You are running ZNC as root! Don't do that! There are not many valid");
+ CUtils::PrintError("reasons for this and it can, in theory, cause great damage!");
+ if (!bAllowRoot) {
+diff --git a/src/znc.cpp b/src/znc.cpp
+index 9469790..297b021 100644
+--- a/src/znc.cpp
++++ b/src/znc.cpp
+@@ -47,6 +47,7 @@ CZNC::CZNC() {
+ m_sConnectThrottle.SetTTL(30000);
+ m_pLockFile = NULL;
+ m_bProtectWebSessions = true;
++ m_bSystemWideConfig = false;
+ }
+
+ CZNC::~CZNC() {
+@@ -952,7 +953,7 @@ bool CZNC::WriteNewConfig(const CString& sConfigFile) {
+ CUtils::PrintMessage("");
+
+ File.UnLock();
+- return bFileOpen && CUtils::GetBoolInput("Launch ZNC now?", true);
++ return bFileOpen && !m_bSystemWideConfig && CUtils::GetBoolInput("Launch ZNC now?", true);
+ }
+
+ size_t CZNC::FilterUncommonModules(set<CModInfo>& ssModules) {
+@@ -1971,3 +1972,7 @@ void CZNC::LeakConnectQueueTimer(CConnectQueueTimer *pTimer) {
+ bool CZNC::WaitForChildLock() {
+ return m_pLockFile && m_pLockFile->ExLock();
+ }
++
++void CZNC::SetSystemWideConfig(bool systemWideConfig) {
++ m_bSystemWideConfig = systemWideConfig;
++}
diff --git a/net-irc/znc/files/znc-1.6.1-create-pidfile-per-default.patch b/net-irc/znc/files/znc-1.6.1-create-pidfile-per-default.patch
new file mode 100644
index 000000000000..8419e9344bf2
--- /dev/null
+++ b/net-irc/znc/files/znc-1.6.1-create-pidfile-per-default.patch
@@ -0,0 +1,23 @@
+Add PidFile option to new configurations per default
+
+Our runscript requires that ZNC creates a pidfile. This patch will add
+the PidFile directive to ZNC's default configuration.
+---
+ src/znc.cpp | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/src/znc.cpp b/src/znc.cpp
+index b33e860..4a02568 100644
+--- a/src/znc.cpp
++++ b/src/znc.cpp
+@@ -575,6 +575,7 @@ bool CZNC::WriteNewConfig(const CString& sConfigFile) {
+ VCString vsLines;
+
+ vsLines.push_back(MakeConfigHeader());
++ vsLines.push_back("PidFile = /run/znc/znc.pid");
+ vsLines.push_back("Version = " + CString(VERSION_STR));
+
+ m_sConfigFile = ExpandConfigPath(sConfigFile);
+--
+2.5.0
+
diff --git a/net-irc/znc/files/znc-1.6.1-systemwideconfig.patch b/net-irc/znc/files/znc-1.6.1-systemwideconfig.patch
new file mode 100644
index 000000000000..d28fa30c219d
--- /dev/null
+++ b/net-irc/znc/files/znc-1.6.1-systemwideconfig.patch
@@ -0,0 +1,215 @@
+Add system-wide daemon support.
+
+This patch adds system-wide daemon support to ZNC so that you can run
+one ZNC instance system-wide using the new "--system-wide-config-as"
+option.
+
+Patch is based on @mrueg version from 2012.
+
+X-Gentoo-Bug: 438430
+X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=438430
+---
+ include/znc/znc.h | 3 ++
+ src/main.cpp | 83 ++++++++++++++++++++++++++++++++++++++++---------------
+ src/znc.cpp | 7 ++++-
+ 3 files changed, 70 insertions(+), 23 deletions(-)
+
+diff --git a/include/znc/znc.h b/include/znc/znc.h
+index cf2326e..16394f9 100644
+--- a/include/znc/znc.h
++++ b/include/znc/znc.h
+@@ -187,6 +187,8 @@ public:
+
+ static void DumpConfig(const CConfig* Config);
+
++ void SetSystemWideConfig(bool systemWideConfig);
++
+ private:
+ CFile* InitPidFile();
+ bool DoRehash(CString& sError);
+@@ -231,6 +233,7 @@ protected:
+ unsigned int m_uiConnectPaused;
+ TCacheMap<CString> m_sConnectThrottle;
+ bool m_bProtectWebSessions;
++ bool m_bSystemWideConfig;
+ bool m_bHideVersion;
+ };
+
+diff --git a/src/main.cpp b/src/main.cpp
+index 09b2c9c..bd5cca6 100644
+--- a/src/main.cpp
++++ b/src/main.cpp
+@@ -16,6 +16,9 @@
+
+ #include <znc/znc.h>
+ #include <signal.h>
++#include <sys/types.h>
++#include <pwd.h>
++#include <grp.h>
+
+ #if defined(HAVE_LIBSSL) && defined(HAVE_PTHREAD)
+ #include <znc/Threads.h>
+@@ -99,34 +102,36 @@ static inline int getopt_long(int argc, char * const argv[], const char *optstri
+ #endif
+
+ static const struct option g_LongOpts[] = {
+- { "help", no_argument, 0, 'h' },
+- { "version", no_argument, 0, 'v' },
+- { "debug", no_argument, 0, 'D' },
+- { "foreground", no_argument, 0, 'f' },
+- { "no-color", no_argument, 0, 'n' },
+- { "allow-root", no_argument, 0, 'r' },
+- { "makeconf", no_argument, 0, 'c' },
+- { "makepass", no_argument, 0, 's' },
+- { "makepem", no_argument, 0, 'p' },
+- { "datadir", required_argument, 0, 'd' },
++ { "help", no_argument, 0, 'h' },
++ { "version", no_argument, 0, 'v' },
++ { "debug", no_argument, 0, 'D' },
++ { "foreground", no_argument, 0, 'f' },
++ { "no-color", no_argument, 0, 'n' },
++ { "allow-root", no_argument, 0, 'r' },
++ { "makeconf", no_argument, 0, 'c' },
++ { "makepass", no_argument, 0, 's' },
++ { "makepem", no_argument, 0, 'p' },
++ { "datadir", required_argument, 0, 'd' },
++ { "system-wide-config-as", required_argument, 0, 'S' },
+ { 0, 0, 0, 0 }
+ };
+
+ static void GenerateHelp(const char *appname) {
+ CUtils::PrintMessage("USAGE: " + CString(appname) + " [options]");
+ CUtils::PrintMessage("Options are:");
+- CUtils::PrintMessage("\t-h, --help List available command line options (this page)");
+- CUtils::PrintMessage("\t-v, --version Output version information and exit");
+- CUtils::PrintMessage("\t-f, --foreground Don't fork into the background");
+- CUtils::PrintMessage("\t-D, --debug Output debugging information (Implies -f)");
+- CUtils::PrintMessage("\t-n, --no-color Don't use escape sequences in the output");
+- CUtils::PrintMessage("\t-r, --allow-root Don't complain if ZNC is run as root");
+- CUtils::PrintMessage("\t-c, --makeconf Interactively create a new config");
+- CUtils::PrintMessage("\t-s, --makepass Generates a password for use in config");
++ CUtils::PrintMessage("\t-h, --help List available command line options (this page)");
++ CUtils::PrintMessage("\t-v, --version Output version information and exit");
++ CUtils::PrintMessage("\t-f, --foreground Don't fork into the background");
++ CUtils::PrintMessage("\t-D, --debug Output debugging information (Implies -f)");
++ CUtils::PrintMessage("\t-n, --no-color Don't use escape sequences in the output");
++ CUtils::PrintMessage("\t-r, --allow-root Don't complain if ZNC is run as root");
++ CUtils::PrintMessage("\t-c, --makeconf Interactively create a new config");
++ CUtils::PrintMessage("\t-s, --makepass Generates a password for use in config");
+ #ifdef HAVE_LIBSSL
+- CUtils::PrintMessage("\t-p, --makepem Generates a pemfile for use with SSL");
++ CUtils::PrintMessage("\t-p, --makepem Generates a pemfile for use with SSL");
+ #endif /* HAVE_LIBSSL */
+- CUtils::PrintMessage("\t-d, --datadir Set a different ZNC repository (default is ~/.znc)");
++ CUtils::PrintMessage("\t-d, --datadir Set a different ZNC repository (default is ~/.znc)");
++ CUtils::PrintMessage("\t-S, --system-wide-config-as Create a system-wide ZNC daemon configuration");
+ }
+
+ static void die(int sig) {
+@@ -192,6 +197,8 @@ int main(int argc, char** argv) {
+ bool bMakeConf = false;
+ bool bMakePass = false;
+ bool bAllowRoot = false;
++ bool bSystemWideConfig = false;
++ CString sSystemWideConfigUser = "znc";
+ bool bForeground = false;
+ #ifdef ALWAYS_RUN_IN_FOREGROUND
+ bForeground = true;
+@@ -201,7 +208,7 @@ int main(int argc, char** argv) {
+ #endif
+ CZNC::CreateInstance();
+
+- while ((iArg = getopt_long(argc, argv, "hvnrcspd:Df", g_LongOpts, &iOptIndex)) != -1) {
++ while ((iArg = getopt_long(argc, argv, "hvnrcspd:DfS:", g_LongOpts, &iOptIndex)) != -1) {
+ switch (iArg) {
+ case 'h':
+ GenerateHelp(argv[0]);
+@@ -219,6 +226,10 @@ int main(int argc, char** argv) {
+ case 'c':
+ bMakeConf = true;
+ break;
++ case 'S':
++ bSystemWideConfig = true;
++ sSystemWideConfigUser = optarg;
++ break;
+ case 's':
+ bMakePass = true;
+ break;
+@@ -254,8 +265,36 @@ int main(int argc, char** argv) {
+ return 1;
+ }
+
++ if (bSystemWideConfig && getuid() == 0) {
++ struct passwd *pwd;
++
++ pwd = getpwnam(sSystemWideConfigUser.c_str());
++ if (pwd == NULL) {
++ CUtils::PrintError("Daemon user not found.");
++ return 1;
++ }
++
++ if ((long) pwd->pw_uid == 0) {
++ CUtils::PrintError("Please define a daemon user other than root.");
++ return 1;
++ }
++ if (setgroups(0, NULL) != 0) {
++ CUtils::PrintError("setgroups: Unable to clear supplementary group IDs");
++ return 1;
++ }
++ if (setgid((long) pwd->pw_gid) != 0) {
++ CUtils::PrintError("setgid: Unable to drop group privileges");
++ return 1;
++ }
++ if (setuid((long) pwd->pw_uid) != 0) {
++ CUtils::PrintError("setuid: Unable to drop user privileges");
++ return 1;
++ }
++ }
++
+ CZNC* pZNC = &CZNC::Get();
+ pZNC->InitDirs(((argc) ? argv[0] : ""), sDataDir);
++ pZNC->SetSystemWideConfig(bSystemWideConfig);
+
+ #ifdef HAVE_LIBSSL
+ if (bMakePem) {
+@@ -304,7 +343,7 @@ int main(int argc, char** argv) {
+ CUtils::PrintStatus(true, "");
+ }
+
+- if (isRoot()) {
++ if (isRoot() && !bSystemWideConfig) {
+ CUtils::PrintError("You are running ZNC as root! Don't do that! There are not many valid");
+ CUtils::PrintError("reasons for this and it can, in theory, cause great damage!");
+ if (!bAllowRoot) {
+diff --git a/src/znc.cpp b/src/znc.cpp
+index 78cda1a..b33e860 100644
+--- a/src/znc.cpp
++++ b/src/znc.cpp
+@@ -55,6 +55,7 @@ CZNC::CZNC() {
+ m_sConnectThrottle.SetTTL(30000);
+ m_pLockFile = NULL;
+ m_bProtectWebSessions = true;
++ m_bSystemWideConfig = false;
+ m_bHideVersion = false;
+ m_uDisabledSSLProtocols = Csock::EDP_SSL;
+ m_sSSLProtocols = "";
+@@ -861,7 +862,7 @@ bool CZNC::WriteNewConfig(const CString& sConfigFile) {
+ CUtils::PrintMessage("");
+
+ File.UnLock();
+- return bFileOpen && CUtils::GetBoolInput("Launch ZNC now?", true);
++ return bFileOpen && !m_bSystemWideConfig && CUtils::GetBoolInput("Launch ZNC now?", true);
+ }
+
+ void CZNC::BackupConfigOnce(const CString& sSuffix) {
+@@ -1973,3 +1974,7 @@ void CZNC::LeakConnectQueueTimer(CConnectQueueTimer *pTimer) {
+ bool CZNC::WaitForChildLock() {
+ return m_pLockFile && m_pLockFile->ExLock();
+ }
++
++void CZNC::SetSystemWideConfig(bool systemWideConfig) {
++ m_bSystemWideConfig = systemWideConfig;
++}
+--
+2.5.0
+
diff --git a/net-irc/znc/files/znc.confd b/net-irc/znc/files/znc.confd
new file mode 100644
index 000000000000..9681f8d792fb
--- /dev/null
+++ b/net-irc/znc/files/znc.confd
@@ -0,0 +1,7 @@
+# /etc/conf.d/znc
+
+# Location of the znc configuration folder
+ZNC_CONF="/var/lib/znc"
+
+# User to run znc as
+ZNC_USER="znc"
diff --git a/net-irc/znc/files/znc.confd-r1 b/net-irc/znc/files/znc.confd-r1
new file mode 100644
index 000000000000..b78e0534b33a
--- /dev/null
+++ b/net-irc/znc/files/znc.confd-r1
@@ -0,0 +1,24 @@
+# /etc/conf.d/znc
+
+# Location of the znc configuration folder
+ZNC_DATADIR="/var/lib/znc"
+
+# User to run znc as
+ZNC_USER="znc"
+
+# Group to run znc as
+ZNC_GROUP="znc"
+
+# PID file
+ZNC_PIDFILE="/run/znc/znc.pid"
+
+# You can use this configuration option to pass additional options to the
+# start-stop-daemon, see start-stop-daemon(8) for more details.
+# Per default we wait 1000ms after we have started the service to ensure
+# that the daemon is really up and running.
+ZNC_SSDARGS="--wait 1000"
+
+# The termination timeout (start-stop-daemon parameter "retry") ensures
+# that the service will be terminated within a given time (30 + 5 seconds
+# per default) when you are stopping the service.
+ZNC_TERMTIMEOUT="TERM/30/KILL/5"
diff --git a/net-irc/znc/files/znc.initd b/net-irc/znc/files/znc.initd
new file mode 100644
index 000000000000..16af8b64c687
--- /dev/null
+++ b/net-irc/znc/files/znc.initd
@@ -0,0 +1,38 @@
+#!/sbin/openrc-run
+# Copyright 1999-2012 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+extra_commands="config"
+extra_started_commands="reload save"
+
+depend() {
+ need net
+}
+
+start() {
+ ebegin "Starting ZNC"
+ start-stop-daemon --start --user ${ZNC_USER} --name znc \
+ --exec /usr/bin/znc -- -d ${ZNC_CONF}
+ eend $?
+}
+
+stop() {
+ ebegin "Stopping ZNC"
+ start-stop-daemon --signal SIGINT --name znc \
+ --exec /usr/bin/znc -- -d ${ZNC_CONF}
+ eend $?
+}
+
+reload() {
+ ebegin "Reloading ZNC Configuration File from Disk"
+ start-stop-daemon --signal SIGHUP --name znc \
+ --exec /usr/bin/znc -- -d ${ZNC_CONF}
+ eend $?
+}
+
+save() {
+ ebegin "Saving ZNC Configuration File to Disk"
+ start-stop-daemon --signal SIGUSR1 --name znc \
+ --exec /usr/bin/znc -- -d ${ZNC_CONF}
+ eend $?
+}
diff --git a/net-irc/znc/files/znc.initd-r1 b/net-irc/znc/files/znc.initd-r1
new file mode 100644
index 000000000000..dedb44b1362f
--- /dev/null
+++ b/net-irc/znc/files/znc.initd-r1
@@ -0,0 +1,39 @@
+#!/sbin/openrc-run
+# Copyright 1999-2015 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+extra_commands="config"
+extra_started_commands="reload save"
+command="/usr/bin/znc"
+command_args="--datadir \"${ZNC_DATADIR}\""
+pidfile="${ZNC_PIDFILE:-/run/znc/znc.pid}"
+user=${ZNC_USER:-znc}
+group=${ZNC_GROUP:-znc}
+start_stop_daemon_args="--chdir \"${ZNC_DATADIR}\" --user ${user} --group ${group} ${ZNC_SSDARGS}"
+retry="${ZNC_TERMTIMEOUT}"
+
+required_dirs="${ZNC_DATADIR}"
+
+depend() {
+ use dns logger
+}
+
+start_pre() {
+ checkpath -d -m 0770 -o ${user}:${group} "$(dirname ${pidfile})"
+}
+
+stop_post() {
+ rm -f "${pidfile}"
+}
+
+reload() {
+ ebegin "Reloading ZNC Configuration File from Disk"
+ start-stop-daemon --signal SIGHUP --pidfile "${pidfile}"
+ eend $?
+}
+
+save() {
+ ebegin "Saving ZNC Configuration File to Disk"
+ start-stop-daemon --signal SIGUSR1 --pidfile "${pidfile}"
+ eend $?
+}
diff --git a/net-irc/znc/files/znc.initd-r2 b/net-irc/znc/files/znc.initd-r2
new file mode 100644
index 000000000000..72834a80da9b
--- /dev/null
+++ b/net-irc/znc/files/znc.initd-r2
@@ -0,0 +1,40 @@
+#!/sbin/openrc-run
+# Copyright 1999-2017 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+extra_commands="config"
+extra_started_commands="reload save"
+command="/usr/bin/znc"
+command_args="--datadir \"${ZNC_DATADIR}\" --foreground"
+command_background="yes"
+pidfile="${ZNC_PIDFILE:-/run/znc/znc.pid}"
+user=${ZNC_USER:-znc}
+group=${ZNC_GROUP:-znc}
+start_stop_daemon_args="--chdir \"${ZNC_DATADIR}\" --user ${user} --group ${group} ${ZNC_SSDARGS}"
+retry="${ZNC_TERMTIMEOUT}"
+
+required_dirs="${ZNC_DATADIR}"
+
+depend() {
+ use dns logger
+}
+
+start_pre() {
+ checkpath -d -m 0770 -o ${user}:${group} "$(dirname ${pidfile})"
+}
+
+stop_post() {
+ rm -f "${pidfile}"
+}
+
+reload() {
+ ebegin "Reloading ZNC Configuration File from Disk"
+ start-stop-daemon --signal SIGHUP --pidfile "${pidfile}"
+ eend $?
+}
+
+save() {
+ ebegin "Saving ZNC Configuration File to Disk"
+ start-stop-daemon --signal SIGUSR1 --pidfile "${pidfile}"
+ eend $?
+}