Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 542168
Collapse All | Expand All

(-)old/net-irc/znc/files/znc-1.0-systemwideconfig.patch (-29 / +97 lines)
Lines 1-8 Link Here
1
Add system-wide daemon support.
2
3
This patch adds system-wide daemon support to ZNC so that you can run
4
one ZNC instance system-wide using the new "--system-wide-config-as"
5
option.
6
7
Patch is based on @mrueg version from 2012.
8
9
X-Gentoo-Bug: 438430
10
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=438430
11
---
12
 include/znc/znc.h |  3 ++
13
 src/main.cpp      | 83 ++++++++++++++++++++++++++++++++++++++++---------------
14
 src/znc.cpp       |  7 ++++-
15
 3 files changed, 70 insertions(+), 23 deletions(-)
16
1
diff --git a/include/znc/znc.h b/include/znc/znc.h
17
diff --git a/include/znc/znc.h b/include/znc/znc.h
2
index 03be646..f493c83 100644
18
index cf2326e..16394f9 100644
3
--- a/include/znc/znc.h
19
--- a/include/znc/znc.h
4
+++ b/include/znc/znc.h
20
+++ b/include/znc/znc.h
5
@@ -169,6 +169,8 @@ public:
21
@@ -187,6 +187,8 @@ public:
6
 
22
 
7
 	static void DumpConfig(const CConfig* Config);
23
 	static void DumpConfig(const CConfig* Config);
8
 
24
 
Lines 11-47 index 03be646..f493c83 100644 Link Here
11
 private:
27
 private:
12
 	CFile* InitPidFile();
28
 	CFile* InitPidFile();
13
 	bool DoRehash(CString& sError);
29
 	bool DoRehash(CString& sError);
14
@@ -209,6 +211,7 @@ protected:
30
@@ -231,6 +233,7 @@ protected:
15
 	unsigned int           m_uiConnectPaused;
31
 	unsigned int           m_uiConnectPaused;
16
 	TCacheMap<CString>     m_sConnectThrottle;
32
 	TCacheMap<CString>     m_sConnectThrottle;
17
 	bool                   m_bProtectWebSessions;
33
 	bool                   m_bProtectWebSessions;
18
+	bool                   m_bSystemWideConfig;
34
+	bool                   m_bSystemWideConfig;
35
 	bool                   m_bHideVersion;
19
 };
36
 };
20
 
37
 
21
 #endif // !_ZNC_H
22
diff --git a/src/main.cpp b/src/main.cpp
38
diff --git a/src/main.cpp b/src/main.cpp
23
index a1f3904..4950911 100644
39
index 09b2c9c..bd5cca6 100644
24
--- a/src/main.cpp
40
--- a/src/main.cpp
25
+++ b/src/main.cpp
41
+++ b/src/main.cpp
26
@@ -10,6 +10,9 @@
42
@@ -16,6 +16,9 @@
27
 #include <znc/FileUtils.h>
43
 
28
 #include <sys/wait.h>
44
 #include <znc/znc.h>
29
 #include <signal.h>
45
 #include <signal.h>
30
+#include <sys/types.h>
46
+#include <sys/types.h>
31
+#include <pwd.h>
47
+#include <pwd.h>
32
+#include <grp.h>
48
+#include <grp.h>
33
 
49
 
34
 using std::cout;
50
 #if defined(HAVE_LIBSSL) && defined(HAVE_PTHREAD)
35
 using std::endl;
51
 #include <znc/Threads.h>
36
@@ -46,6 +49,7 @@ static const struct option g_LongOpts[] = {
52
@@ -99,34 +102,36 @@ static inline int getopt_long(int argc, char * const argv[], const char *optstri
37
 	{ "makepass",    no_argument,       0, 's' },
53
 #endif
38
 	{ "makepem",     no_argument,       0, 'p' },
54
 
39
 	{ "datadir",     required_argument, 0, 'd' },
55
 static const struct option g_LongOpts[] = {
40
+	{ "system-wide-config-as",      required_argument, 0, 'S' },
56
-	{ "help",        no_argument,       0, 'h' },
57
-	{ "version",     no_argument,       0, 'v' },
58
-	{ "debug",       no_argument,       0, 'D' },
59
-	{ "foreground",  no_argument,       0, 'f' },
60
-	{ "no-color",    no_argument,       0, 'n' },
61
-	{ "allow-root",  no_argument,       0, 'r' },
62
-	{ "makeconf",    no_argument,       0, 'c' },
63
-	{ "makepass",    no_argument,       0, 's' },
64
-	{ "makepem",     no_argument,       0, 'p' },
65
-	{ "datadir",     required_argument, 0, 'd' },
66
+	{ "help",                  no_argument,       0, 'h' },
67
+	{ "version",               no_argument,       0, 'v' },
68
+	{ "debug",                 no_argument,       0, 'D' },
69
+	{ "foreground",            no_argument,       0, 'f' },
70
+	{ "no-color",              no_argument,       0, 'n' },
71
+	{ "allow-root",            no_argument,       0, 'r' },
72
+	{ "makeconf",              no_argument,       0, 'c' },
73
+	{ "makepass",              no_argument,       0, 's' },
74
+	{ "makepem",               no_argument,       0, 'p' },
75
+	{ "datadir",               required_argument, 0, 'd' },
76
+	{ "system-wide-config-as", required_argument, 0, 'S' },
41
 	{ 0, 0, 0, 0 }
77
 	{ 0, 0, 0, 0 }
42
 };
78
 };
43
 
79
 
44
@@ -127,6 +131,8 @@ int main(int argc, char** argv) {
80
 static void GenerateHelp(const char *appname) {
81
 	CUtils::PrintMessage("USAGE: " + CString(appname) + " [options]");
82
 	CUtils::PrintMessage("Options are:");
83
-	CUtils::PrintMessage("\t-h, --help         List available command line options (this page)");
84
-	CUtils::PrintMessage("\t-v, --version      Output version information and exit");
85
-	CUtils::PrintMessage("\t-f, --foreground   Don't fork into the background");
86
-	CUtils::PrintMessage("\t-D, --debug        Output debugging information (Implies -f)");
87
-	CUtils::PrintMessage("\t-n, --no-color     Don't use escape sequences in the output");
88
-	CUtils::PrintMessage("\t-r, --allow-root   Don't complain if ZNC is run as root");
89
-	CUtils::PrintMessage("\t-c, --makeconf     Interactively create a new config");
90
-	CUtils::PrintMessage("\t-s, --makepass     Generates a password for use in config");
91
+	CUtils::PrintMessage("\t-h, --help                    List available command line options (this page)");
92
+	CUtils::PrintMessage("\t-v, --version                 Output version information and exit");
93
+	CUtils::PrintMessage("\t-f, --foreground              Don't fork into the background");
94
+	CUtils::PrintMessage("\t-D, --debug                   Output debugging information (Implies -f)");
95
+	CUtils::PrintMessage("\t-n, --no-color                Don't use escape sequences in the output");
96
+	CUtils::PrintMessage("\t-r, --allow-root              Don't complain if ZNC is run as root");
97
+	CUtils::PrintMessage("\t-c, --makeconf                Interactively create a new config");
98
+	CUtils::PrintMessage("\t-s, --makepass                Generates a password for use in config");
99
 #ifdef HAVE_LIBSSL
100
-	CUtils::PrintMessage("\t-p, --makepem      Generates a pemfile for use with SSL");
101
+	CUtils::PrintMessage("\t-p, --makepem                 Generates a pemfile for use with SSL");
102
 #endif /* HAVE_LIBSSL */
103
-	CUtils::PrintMessage("\t-d, --datadir      Set a different ZNC repository (default is ~/.znc)");
104
+	CUtils::PrintMessage("\t-d, --datadir                 Set a different ZNC repository (default is ~/.znc)");
105
+	CUtils::PrintMessage("\t-S, --system-wide-config-as   Create a system-wide ZNC daemon configuration");
106
 }
107
 
108
 static void die(int sig) {
109
@@ -192,6 +197,8 @@ int main(int argc, char** argv) {
45
 	bool bMakeConf = false;
110
 	bool bMakeConf = false;
46
 	bool bMakePass = false;
111
 	bool bMakePass = false;
47
 	bool bAllowRoot = false;
112
 	bool bAllowRoot = false;
Lines 50-65 index a1f3904..4950911 100644 Link Here
50
 	bool bForeground = false;
115
 	bool bForeground = false;
51
 #ifdef ALWAYS_RUN_IN_FOREGROUND
116
 #ifdef ALWAYS_RUN_IN_FOREGROUND
52
 	bForeground = true;
117
 	bForeground = true;
53
@@ -135,7 +141,7 @@ int main(int argc, char** argv) {
118
@@ -201,7 +208,7 @@ int main(int argc, char** argv) {
54
 	bool bMakePem = false;
55
 #endif
119
 #endif
120
 	CZNC::CreateInstance();
56
 
121
 
57
-	while ((iArg = getopt_long(argc, argv, "hvnrcspd:Df", g_LongOpts, &iOptIndex)) != -1) {
122
-	while ((iArg = getopt_long(argc, argv, "hvnrcspd:Df", g_LongOpts, &iOptIndex)) != -1) {
58
+	while ((iArg = getopt_long(argc, argv, "hvnrcspd:DfS:", g_LongOpts, &iOptIndex)) != -1) {
123
+	while ((iArg = getopt_long(argc, argv, "hvnrcspd:DfS:", g_LongOpts, &iOptIndex)) != -1) {
59
 		switch (iArg) {
124
 		switch (iArg) {
60
 		case 'h':
125
 		case 'h':
61
 			GenerateHelp(argv[0]);
126
 			GenerateHelp(argv[0]);
62
@@ -153,6 +159,10 @@ int main(int argc, char** argv) {
127
@@ -219,6 +226,10 @@ int main(int argc, char** argv) {
63
 		case 'c':
128
 		case 'c':
64
 			bMakeConf = true;
129
 			bMakeConf = true;
65
 			break;
130
 			break;
Lines 70-76 index a1f3904..4950911 100644 Link Here
70
 		case 's':
135
 		case 's':
71
 			bMakePass = true;
136
 			bMakePass = true;
72
 			break;
137
 			break;
73
@@ -187,8 +197,36 @@ int main(int argc, char** argv) {
138
@@ -254,8 +265,36 @@ int main(int argc, char** argv) {
74
 		return 1;
139
 		return 1;
75
 	}
140
 	}
76
 
141
 
Lines 107-113 index a1f3904..4950911 100644 Link Here
107
 
172
 
108
 #ifdef HAVE_LIBSSL
173
 #ifdef HAVE_LIBSSL
109
 	if (bMakePem) {
174
 	if (bMakePem) {
110
@@ -229,7 +267,7 @@ int main(int argc, char** argv) {
175
@@ -304,7 +343,7 @@ int main(int argc, char** argv) {
111
 		CUtils::PrintStatus(true, "");
176
 		CUtils::PrintStatus(true, "");
112
 	}
177
 	}
113
 
178
 
Lines 117-134 index a1f3904..4950911 100644 Link Here
117
 		CUtils::PrintError("reasons for this and it can, in theory, cause great damage!");
182
 		CUtils::PrintError("reasons for this and it can, in theory, cause great damage!");
118
 		if (!bAllowRoot) {
183
 		if (!bAllowRoot) {
119
diff --git a/src/znc.cpp b/src/znc.cpp
184
diff --git a/src/znc.cpp b/src/znc.cpp
120
index 9469790..297b021 100644
185
index 78cda1a..b33e860 100644
121
--- a/src/znc.cpp
186
--- a/src/znc.cpp
122
+++ b/src/znc.cpp
187
+++ b/src/znc.cpp
123
@@ -47,6 +47,7 @@ CZNC::CZNC() {
188
@@ -55,6 +55,7 @@ CZNC::CZNC() {
124
 	m_sConnectThrottle.SetTTL(30000);
189
 	m_sConnectThrottle.SetTTL(30000);
125
 	m_pLockFile = NULL;
190
 	m_pLockFile = NULL;
126
 	m_bProtectWebSessions = true;
191
 	m_bProtectWebSessions = true;
127
+	m_bSystemWideConfig = false;
192
+	m_bSystemWideConfig = false;
128
 }
193
 	m_bHideVersion = false;
129
 
194
 	m_uDisabledSSLProtocols = Csock::EDP_SSL;
130
 CZNC::~CZNC() {
195
 	m_sSSLProtocols = "";
131
@@ -952,7 +953,7 @@ bool CZNC::WriteNewConfig(const CString& sConfigFile) {
196
@@ -861,7 +862,7 @@ bool CZNC::WriteNewConfig(const CString& sConfigFile) {
132
 	CUtils::PrintMessage("");
197
 	CUtils::PrintMessage("");
133
 
198
 
134
 	File.UnLock();
199
 	File.UnLock();
Lines 136-143 index 9469790..297b021 100644 Link Here
136
+	return bFileOpen && !m_bSystemWideConfig && CUtils::GetBoolInput("Launch ZNC now?", true);
201
+	return bFileOpen && !m_bSystemWideConfig && CUtils::GetBoolInput("Launch ZNC now?", true);
137
 }
202
 }
138
 
203
 
139
 size_t CZNC::FilterUncommonModules(set<CModInfo>& ssModules) {
204
 void CZNC::BackupConfigOnce(const CString& sSuffix) {
140
@@ -1971,3 +1972,7 @@ void CZNC::LeakConnectQueueTimer(CConnectQueueTimer *pTimer) {
205
@@ -1973,3 +1974,7 @@ void CZNC::LeakConnectQueueTimer(CConnectQueueTimer *pTimer) {
141
 bool CZNC::WaitForChildLock() {
206
 bool CZNC::WaitForChildLock() {
142
 	return m_pLockFile && m_pLockFile->ExLock();
207
 	return m_pLockFile && m_pLockFile->ExLock();
143
 }
208
 }
Lines 145-147 index 9469790..297b021 100644 Link Here
145
+void CZNC::SetSystemWideConfig(bool systemWideConfig) {
210
+void CZNC::SetSystemWideConfig(bool systemWideConfig) {
146
+	m_bSystemWideConfig = systemWideConfig;
211
+	m_bSystemWideConfig = systemWideConfig;
147
+}
212
+}
213
-- 
214
2.5.0
215
(-)old/net-irc/znc/files/znc-1.6.1-create-pidfile-per-default.patch (+23 lines)
Line 0 Link Here
1
Add PidFile option to new configurations per default
2
3
Our runscript requires that ZNC creates a pidfile. This patch will add
4
the PidFile directive to ZNC's default configuration.
5
---
6
 src/znc.cpp | 1 +
7
 1 file changed, 1 insertion(+)
8
9
diff --git a/src/znc.cpp b/src/znc.cpp
10
index b33e860..4a02568 100644
11
--- a/src/znc.cpp
12
+++ b/src/znc.cpp
13
@@ -575,6 +575,7 @@ bool CZNC::WriteNewConfig(const CString& sConfigFile) {
14
 	VCString vsLines;
15
 
16
 	vsLines.push_back(MakeConfigHeader());
17
+	vsLines.push_back("PidFile = /run/znc/znc.pid");
18
 	vsLines.push_back("Version = " + CString(VERSION_STR));
19
 
20
 	m_sConfigFile = ExpandConfigPath(sConfigFile);
21
-- 
22
2.5.0
23
(-)old/net-irc/znc/files/znc.confd (-1 / +18 lines)
Lines 1-7 Link Here
1
# /etc/conf.d/znc
1
# /etc/conf.d/znc
2
2
3
# Location of the znc configuration folder
3
# Location of the znc configuration folder
4
ZNC_CONF="/var/lib/znc"
4
ZNC_DATADIR="/var/lib/znc"
5
5
6
# User to run znc as
6
# User to run znc as
7
ZNC_USER="znc"
7
ZNC_USER="znc"
8
9
# Group to run znc as
10
ZNC_GROUP="znc"
11
12
# PID file
13
ZNC_PIDFILE="/run/znc/znc.pid"
14
15
# You can use this configuration option to pass additional options to the
16
# start-stop-daemon, see start-stop-daemon(8) for more details.
17
# Per default we wait 1000ms after we have started the service to ensure
18
# that the daemon is really up and running.
19
ZNC_SSDARGS="--wait 1000"
20
21
# The termination timeout (start-stop-daemon parameter "retry") ensures
22
# that the service will be terminated within a given time (30 + 5 seconds
23
# per default) when you are stopping the service.
24
ZNC_TERMTIMEOUT="TERM/30/KILL/5"
(-)old/net-irc/znc/files/znc.initd (-15 / +16 lines)
Lines 5-39 Link Here
5
5
6
extra_commands="config"
6
extra_commands="config"
7
extra_started_commands="reload save"
7
extra_started_commands="reload save"
8
command="/usr/bin/znc"
9
command_args="--datadir ${ZNC_DATADIR}"
10
pidfile="${ZNC_PIDFILE:-/run/znc/znc.pid}"
11
user=${ZNC_USER:-znc}
12
group=${ZNC_GROUP:-znc}
13
start_stop_daemon_args="--chdir \"${ZNC_DATADIR}\" --user ${user} --group ${group} ${ZNC_SSDARGS}"
14
retry="${ZNC_TERMTIMEOUT}"
15
16
required_dirs="${ZNC_DATADIR}"
8
17
9
depend() {
18
depend() {
10
	need net
19
	use dns logger
11
}
20
}
12
21
13
start() {
22
start_pre() {
14
	ebegin "Starting ZNC"
23
	checkpath -d -m 0770 -o ${user}:${group} $(dirname ${pidfile})
15
	start-stop-daemon --start --user ${ZNC_USER} --name znc \
16
		--exec /usr/bin/znc -- -d ${ZNC_CONF}
17
	eend $?
18
}
24
}
19
25
20
stop() {
26
stop_post() {
21
	ebegin "Stopping ZNC"
27
	rm -f ${pidfile}
22
	start-stop-daemon --signal SIGINT --name znc \
23
		--exec /usr/bin/znc -- -d ${ZNC_CONF}
24
	eend $?
25
}
28
}
26
29
27
reload() {
30
reload() {
28
	ebegin "Reloading ZNC Configuration File from Disk"
31
	ebegin "Reloading ZNC Configuration File from Disk"
29
	start-stop-daemon --signal SIGHUP --name znc \
32
	start-stop-daemon --signal SIGHUP --pidfile ${pidfile}
30
		--exec /usr/bin/znc -- -d ${ZNC_CONF}
31
	eend $?
33
	eend $?
32
}
34
}
33
35
34
save() {
36
save() {
35
	ebegin "Saving ZNC Configuration File to Disk"
37
	ebegin "Saving ZNC Configuration File to Disk"
36
	start-stop-daemon --signal SIGUSR1 --name znc \
38
	start-stop-daemon --signal SIGUSR1 --pidfile ${pidfile}
37
		--exec /usr/bin/znc -- -d ${ZNC_CONF}
38
	eend $?
39
	eend $?
39
}
40
}
(-)old/net-irc/znc/znc-1.4-r1.ebuild (-25 / +55 lines)
Lines 8-29 PYTHON_COMPAT=( python{3_3,3_4} ) Link Here
8
inherit base python-single-r1 systemd user
8
inherit base python-single-r1 systemd user
9
9
10
MY_PV=${PV/_/-}
10
MY_PV=${PV/_/-}
11
GTEST_VER="1.7.0"
12
GTEST_URL="https://googletest.googlecode.com/files/gtest-${GTEST_VER}.zip"
11
DESCRIPTION="An advanced IRC Bouncer"
13
DESCRIPTION="An advanced IRC Bouncer"
12
14
13
if [[ ${PV} == *9999* ]]; then
15
if [[ ${PV} == "9999" ]]; then
14
	inherit git-2
16
	inherit git-r3
15
	EGIT_REPO_URI=${EGIT_REPO_URI:-"git://github.com/znc/znc.git"}
17
	EGIT_REPO_URI="git://github.com/znc/znc.git"
16
	SRC_URI=""
18
	SRC_URI="test? ( ${GTEST_URL} )"
17
	KEYWORDS=""
19
	KEYWORDS=""
18
else
20
else
19
	SRC_URI="http://znc.in/releases/${PN}-${MY_PV}.tar.gz"
21
	SRC_URI="http://znc.in/releases/${PN}-${MY_PV}.tar.gz
20
	KEYWORDS="amd64 ~arm ~x86"
22
		test? ( ${GTEST_URL} )"
23
	KEYWORDS="~amd64 ~x86"
21
fi
24
fi
22
25
23
HOMEPAGE="http://znc.in"
26
HOMEPAGE="http://znc.in"
24
LICENSE="GPL-2"
27
LICENSE="GPL-2"
25
SLOT="0"
28
SLOT="0"
26
IUSE="daemon debug ipv6 perl python ssl sasl tcl"
29
IUSE="daemon debug ipv6 perl python ssl sasl tcl test"
27
30
28
REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
31
REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
29
32
Lines 48-57 DEPEND=" Link Here
48
S=${WORKDIR}/${PN}-${MY_PV}
51
S=${WORKDIR}/${PN}-${MY_PV}
49
52
50
PATCHES=(
53
PATCHES=(
51
	"${FILESDIR}/${PN}-1.0-systemwideconfig.patch"
54
	"${FILESDIR}"/${PN}-1.6.1-systemwideconfig.patch
55
	"${FILESDIR}"/${PN}-1.6.1-create-pidfile-per-default.patch
52
)
56
)
53
57
54
CONFDIR="/var/lib/znc"
58
ZNC_DATADIR="${ZNC_DATADIR:-"/var/lib/znc"}"
55
59
56
pkg_setup() {
60
pkg_setup() {
57
	if use python; then
61
	if use python; then
Lines 63-68 pkg_setup() { Link Here
63
	fi
67
	fi
64
}
68
}
65
69
70
src_unpack() {
71
	if [[ ${PV} == "9999" ]] ; then
72
		git-r3_src_unpack
73
	else
74
		default
75
	fi
76
77
	if use test; then
78
		cd "${S}"/test || die "Failed to chdir into '${S}/test'"
79
		unpack $(basename ${GTEST_URL})
80
		mv gtest-${GTEST_VER} gtest || die "Failed to rename '${S}/test/gtest-${GTEST_VER}' dir"
81
	fi
82
}
83
66
src_prepare() {
84
src_prepare() {
67
	if [[ ${PV} == *9999* ]]; then
85
	if [[ ${PV} == *9999* ]]; then
68
		./autogen.sh
86
		./autogen.sh
Lines 80-90 src_configure() { Link Here
80
		$(use python && echo "--enable-python=python3") \
98
		$(use python && echo "--enable-python=python3") \
81
		$(use_enable sasl cyrus) \
99
		$(use_enable sasl cyrus) \
82
		$(use_enable ssl openssl) \
100
		$(use_enable ssl openssl) \
83
		$(use_enable tcl tcl)
101
		$(use_enable tcl tcl) \
102
		$(use_with test gtest "${S}/test/gtest")
84
}
103
}
85
104
86
src_install() {
105
src_install() {
87
	emake install DESTDIR="${D}"
106
	emake install DESTDIR="${D%/}"
88
	dodoc NOTICE README.md
107
	dodoc NOTICE README.md
89
	if use daemon; then
108
	if use daemon; then
90
		newinitd "${FILESDIR}"/znc.initd znc
109
		newinitd "${FILESDIR}"/znc.initd znc
Lines 102-154 pkg_postinst() { Link Here
102
		elog
121
		elog
103
		elog "An init-script was installed in /etc/init.d"
122
		elog "An init-script was installed in /etc/init.d"
104
		elog "A config file was installed in /etc/conf.d"
123
		elog "A config file was installed in /etc/conf.d"
105
		if [[ ! -d "${EROOT}${CONFDIR}" ]]; then
124
		if [[ ! -d "${EROOT}${ZNC_DATADIR}" ]]; then
106
			elog
125
			elog
107
			elog "Run 'emerge --config znc' to configure ZNC"
126
			elog "Run 'emerge --config znc' to configure ZNC"
108
			elog "as a system-wide daemon."
127
			elog "as a system-wide daemon."
109
			elog
128
			elog
110
			elog "To generate a new SSL certificate, run:"
129
			elog "To generate a new SSL certificate, run:"
111
			elog "  znc --system-wide-config-as znc --makepem -d ${CONFDIR}"
130
			elog "  znc --system-wide-config-as znc --makepem -d ${ZNC_DATADIR}"
112
			elog "as root"
131
			elog "as root"
113
			elog
132
			elog
114
			elog "If migrating from a user-based install"
133
			elog "If migrating from a user-based install"
115
			elog "you can use your existing config files:"
134
			elog "you can use your existing config files:"
116
			elog "  mkdir ${CONFDIR}"
135
			elog "  mkdir ${ZNC_DATADIR}"
117
			elog "  mv /home/\$USER/.znc/* ${CONFDIR}"
136
			elog "  mv /home/\$USER/.znc/* ${ZNC_DATADIR}"
118
			elog "  rm -rf /home/\$USER/.znc"
137
			elog "  rm -rf /home/\$USER/.znc"
119
			elog "  chown -R znc:znc ${CONFDIR}"
138
			elog "  chown -R znc:znc ${ZNC_DATADIR}"
120
			elog
139
			elog
121
			elog "If you already have znc set up and want take advantage of the"
140
			elog "If you already have znc set up and want take advantage of the"
122
			elog "init script but skip of all the above, you can also edit"
141
			elog "init script but skip of all the above, you can also edit"
123
			elog "  /etc/conf.d/znc"
142
			elog "  /etc/conf.d/znc"
124
			elog "and adjust the variables to your current znc user and config"
143
			elog "and adjust the variables to your current znc user and config"
125
			elog "location."
144
			elog "location."
145
			elog
146
			elog "Please make sure that your existing configuration contains"
147
			elog "  PidFile = /run/znc/znc.pid"
148
			elog "or that PidFile value matches the one in /etc/conf.d/znc"
126
			if [[ -d "${EROOT}"/etc/znc ]]; then
149
			if [[ -d "${EROOT}"/etc/znc ]]; then
127
				elog
150
				elog
128
				ewarn "/etc/znc exists on your system."
151
				ewarn "/etc/znc exists on your system."
129
				ewarn "Due to the nature of the contents of that folder,"
152
				ewarn "Due to the nature of the contents of that folder,"
130
				ewarn "we have changed the default configuration to use"
153
				ewarn "we have changed the default configuration to use"
131
				ewarn "	/var/lib/znc"
154
				ewarn "	${ZNC_DATADIR}"
132
				ewarn "please move /etc/znc to /var/lib/znc"
155
				ewarn "please move /etc/znc to ${ZNC_DATADIR}"
133
				ewarn "or adjust /etc/conf.d/znc"
156
				ewarn "or adjust /etc/conf.d/znc"
134
			fi
157
			fi
135
		else
158
		else
136
			elog "Existing config detected in ${CONFDIR}"
159
			elog "Existing config detected in ${ZNC_DATADIR}"
137
			elog "You're good to go :)"
160
			if ! systemd_is_booted; then
161
				elog
162
				elog "Please make sure that your existing configuration contains"
163
				elog "  PidFile = /run/znc/znc.pid"
164
				elog "or that PidFile value matches the one in /etc/conf.d/znc"
165
			else
166
				elog "You're good to go :)"
167
			fi
138
		fi
168
		fi
139
		elog
169
		elog
140
	fi
170
	fi
141
}
171
}
142
172
143
pkg_config() {
173
pkg_config() {
144
	if use daemon && ! [[ -d "${EROOT}${CONFDIR}" ]]; then
174
	if use daemon && ! [[ -d "${EROOT}${ZNC_DATADIR}" ]]; then
145
		einfo "Press ENTER to interactively create a new configuration file for znc."
175
		einfo "Press ENTER to interactively create a new configuration file for znc."
146
		einfo "To abort, press Control-C"
176
		einfo "To abort, press Control-C"
147
		read
177
		read
148
		mkdir -p "${EROOT}${CONFDIR}" || die
178
		mkdir -p "${EROOT}${ZNC_DATADIR}" || die
149
		chown -R ${PN}:${PN} "${EROOT}${CONFDIR}" ||
179
		chown -R ${PN}:${PN} "${EROOT}${ZNC_DATADIR}" ||
150
			die "Setting permissions failed"
180
			die "Setting permissions failed"
151
		"${EROOT}"/usr/bin/znc --system-wide-config-as znc -c -r -d "${EROOT}${CONFDIR}" ||
181
		"${EROOT}"/usr/bin/znc --system-wide-config-as znc -c -r -d "${EROOT}${ZNC_DATADIR}" ||
152
			die "Config failed"
182
			die "Config failed"
153
		echo
183
		echo
154
		einfo "To start znc, run '/etc/init.d/znc start'"
184
		einfo "To start znc, run '/etc/init.d/znc start'"
Lines 156-162 pkg_config() { Link Here
156
		einfo "  rc-update add znc default"
186
		einfo "  rc-update add znc default"
157
	else
187
	else
158
		if use daemon; then
188
		if use daemon; then
159
			ewarn "${CONFDIR} already exists, aborting to avoid damaging"
189
			ewarn "${ZNC_DATADIR} already exists, aborting to avoid damaging"
160
			ewarn "any existing configuration. If you are sure you want"
190
			ewarn "any existing configuration. If you are sure you want"
161
			ewarn "to generate a new configuration, remove the folder"
191
			ewarn "to generate a new configuration, remove the folder"
162
			ewarn "and try again."
192
			ewarn "and try again."

Return to bug 542168