wildduck/setup/10_install_wildduck_webmail.sh
BUNYEVACZ Sandor 88ee4c9ede Breaking up install.sh into chapters
Fixed two issues:
82: need to install npm globally to get around permission problems
83: need to start nginx service before restarting it

Better executable requirements (lsof, ps). It may be not installed
on minimal systems.

Better service detection on given port. It is especially useful,
if the installation.sh got interrupted for some reason, and
already installed some services.

Minor doc update, so a single line is required to paste in terminal.
curl vs. wget -> stayed with wget, it is installed by default on ubuntu

Colors: added color support for the terminal output:)
2018-06-08 08:56:41 +02:00

63 lines
1.9 KiB
Bash

#! /bin/bash
OURNAME=10_install_wildduck_webmail.sh
echo -e "\n-- Executing ${ORANGE}${OURNAME}${NC} subscript --"
#### WWW ####
####
# clear previous install
if [ -f "/etc/systemd/system/wildduck-webmail.service" ]
then
$SYSTEMCTL_PATH stop wildduck-webmail || true
$SYSTEMCTL_PATH disable wildduck-webmail || true
rm -rf /etc/systemd/system/wildduck-webmail.service
fi
rm -rf /var/opt/wildduck-webmail.git
rm -rf /opt/wildduck-webmail
# fresh install
cd /var/opt
git clone --bare git://github.com/nodemailer/wildduck-webmail.git
# create update hook so we can later deploy to this location
hook_script_bower wildduck-webmail
chmod +x /var/opt/wildduck-webmail.git/hooks/update
# allow deploy user to restart zone-mta service
echo "deploy ALL = (root) NOPASSWD: $SYSTEMCTL_PATH restart wildduck-webmail" >> /etc/sudoers.d/wildduck-webmail
# checkout files from git to working directory
mkdir -p /opt/wildduck-webmail
git --git-dir=/var/opt/wildduck-webmail.git --work-tree=/opt/wildduck-webmail checkout "$WEBMAIL_COMMIT"
cp /opt/wildduck-webmail/config/default.toml /etc/wildduck/wildduck-webmail.toml
sed -i -e "s/localhost/$HOSTNAME/g;s/999/99/g;s/2587/587/g;s/proxy=false/proxy=true/g" /etc/wildduck/wildduck-webmail.toml
cd /opt/wildduck-webmail
chown -R deploy:deploy /var/opt/wildduck-webmail.git
chown -R deploy:deploy /opt/wildduck-webmail
# we need to run bower which reject root
HOME=/home/deploy sudo -u deploy npm install
HOME=/home/deploy sudo -u deploy npm run bowerdeps
echo '[Unit]
Description=Wildduck Webmail
After=wildduck.service
[Service]
Environment="NODE_ENV=production"
WorkingDirectory=/opt/wildduck-webmail
ExecStart=/usr/bin/node server.js --config="/etc/wildduck/wildduck-webmail.toml"
ExecReload=/bin/kill -HUP $MAINPID
Type=simple
Restart=always
SyslogIdentifier=wildduck-www
[Install]
WantedBy=multi-user.target' > /etc/systemd/system/wildduck-webmail.service
$SYSTEMCTL_PATH enable wildduck-webmail.service