forked from SynoCommunity/spksrc
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathservice-setup.sh
More file actions
43 lines (36 loc) · 1.47 KB
/
service-setup.sh
File metadata and controls
43 lines (36 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# znc service setup
# Sourced by generic installer and start-stop-status scripts
# Set generic service startup, run service in background
PATH="${SYNOPKG_PKGDEST}/bin:${PATH}"
ZNC="${SYNOPKG_PKGDEST}/bin/znc"
CERT_FILE="${SYNOPKG_PKGVAR}/znc.pem"
SERVICE_COMMAND="strace -o ${SYNOPKG_PKGVAR}/znc-strace.log ${ZNC} -d ${SYNOPKG_PKGVAR} --debug --foreground"
SVC_BACKGROUND=yes
CONF_FILE=${SYNOPKG_PKGVAR}/configs/znc.conf
OID_FILE=${SYNOPKG_PKGVAR}/configs/oidentd.conf
# DEBUG
export ZNC_DEBUG_MODULES=1
export ZNC_DEBUG_SSL=1
# Disable SHA-NI hardware encryption as celeron CPU models does not support it
# https://github.com/SynoCommunity/spksrc/issues/6640
export OPENSSL_ia32cap=":~0x20000000"
service_postinst ()
{
# Edit the configuration according to the wizard
sed -i -e "s,@pidfile@,${PID_FILE},g" ${CONF_FILE}
sed -i -e "s,@certfile@,${CERT_FILE},g" ${CONF_FILE}
sed -i -e "s,@username@,${wizard_username:=admin},g" ${CONF_FILE}
sed -i -e "s,@password@,${wizard_password:=admin},g" ${CONF_FILE}
sed -i -e "s,@zncuser@,${EFF_USER},g" ${OID_FILE}
}
service_prestart ()
{
# Generate certificate if it does not exist (on first run)
if [ -e "${CERT_FILE}" ]; then
echo "Certificate file exists. Starting..." >> ${LOG_FILE}
else
echo "Generating initial certificate file" >> ${LOG_FILE}
${ZNC} -d ${SYNOPKG_PKGVAR} -p >> ${LOG_FILE}
echo "Certificate file created. Starting..." >> ${LOG_FILE}
fi
}