2021-01-14 19:41:49 +08:00
|
|
|
#!/bin/bash
|
|
|
|
|
2018-01-04 15:28:16 +08:00
|
|
|
ETC='/opt/key-networks/ztncui/etc'
|
2021-01-14 19:41:49 +08:00
|
|
|
if [ -f ${ETC}/passwd ]; then
|
|
|
|
echo "Password file aready exists"
|
|
|
|
else
|
|
|
|
echo "Copying default password file..."
|
|
|
|
cp -pv ${ETC}/default.passwd ${ETC}/passwd
|
|
|
|
fi
|
|
|
|
if [ -f /opt/key-networks/ztncui/etc/tls/privkey.pem ] && [ -f /opt/key-networks/ztncui/etc/tls/fullchain.pem ]; then
|
|
|
|
echo "TLS key and certificate already exist"
|
|
|
|
else
|
|
|
|
echo "Generating new TLS key and self-signed certificate..."
|
|
|
|
openssl req -x509 -sha256 -nodes -days 365 -newkey rsa:2048 -keyout /opt/key-networks/ztncui/etc/tls/privkey.pem -out /opt/key-networks/ztncui/etc/tls/fullchain.pem -subj "/C=XX/ST=YY/L=ZZ/O=Security/OU=SelfSigned/CN=example.com"
|
|
|
|
fi
|
|
|
|
chown ztncui.ztncui /opt/key-networks/ztncui/etc/tls/*
|
2018-01-05 11:36:55 +08:00
|
|
|
echo "Enabling and starting ztncui service..."
|
2018-01-09 19:48:39 +08:00
|
|
|
systemctl enable ztncui
|
|
|
|
systemctl start ztncui
|