83 lines
3.3 KiB
Bash
83 lines
3.3 KiB
Bash
#!/bin/ash
|
|
##Installer for MailBackup-sys on Alpine Linux
|
|
#Goto ProjectRoot
|
|
cd "$( dirname "$0" )"
|
|
|
|
#Intergration check
|
|
if [ -z ${DistoBuilderINT+x} ]; then
|
|
ResourceFolder=/tmp
|
|
#Install required software
|
|
apk add dovecot php8-xml php8-fpm php8-curl php8-dom php8-zip php8-mbstring php-openssl py3-pip sudo curl openssl
|
|
#Install Nginx and Nginx Repo
|
|
wget https://nginx.org/keys/nginx_signing.rsa.pub -O /etc/apk/keys/nginx_signing.rsa.pub
|
|
echo "@nginx http://nginx.org/packages/mainline/alpine/v$(egrep -o '^[0-9]+\.[0-9]+' /etc/alpine-release)/main" >> /etc/apk/repositories
|
|
curl -L https://nginx.org/keys/nginx_signing.rsa.pub -o /etc/apk/keys/nginx_signing.rsa.pub
|
|
apk add nginx@nginx
|
|
fi
|
|
|
|
#Download Resources
|
|
OfflineIMAPVer=$(curl -s https://api.github.com/repos/OfflineIMAP/offlineimap3/tags | grep 'name.*' |head -n 1 | cut -d : -f 2,3 | tr -d \" |tr -d , |tr -d " ")
|
|
SnappyMailVer=$(curl -s https://api.github.com/repos/the-djmaze/snappymail/releases/latest | grep 'tag_name.*' | cut -d : -f 2,3 | tr -d \" |tr -d , |tr -d " ")
|
|
echo "$OfflineIMAPVer" > /opt/OfflineIMAP3-installed
|
|
echo "$SnappyMailVer" > /opt/SnappyMail-installed
|
|
https://github.com/the-djmaze/snappymail/releases/download/v2.17.4/snappymail-2.17.4.tar.gz
|
|
curl -L https://github.com/the-djmaze/snappymail/releases/download/$SnappyMailVer/snappymail-${SnappyMailVer//v}.tar.gz -o /tmp/smc.tar.gz || exit 1
|
|
curl -L https://github.com/OfflineIMAP/offlineimap3/archive/refs/tags/$OfflineIMAPVer.tar.gz -o /tmp/olim3.tar.gz || exit 1
|
|
|
|
#Configure Nginx
|
|
rm -rf /etc/nginx/conf.d/*
|
|
mv Configs/nginx.conf /etc/nginx/nginx.conf
|
|
mkdir /var/www
|
|
mv Resources/Custom-index.html /var/www/index.html
|
|
|
|
#Configure Dovecot
|
|
rm -rf /etc/dovecot/*
|
|
mv Configs/dovecot.conf /etc/dovecot/dovecot.conf
|
|
mkdir /mail
|
|
chmod 777 /mail
|
|
|
|
#Configure Php-fpm
|
|
rm /etc/php8/php-fpm.d/*
|
|
mv Configs/php.conf /etc/php8/php-fpm.d/railoop.conf
|
|
|
|
#Install Webmail
|
|
tar -C /opt/webmail -xzf /tmp/smc.tar.gz
|
|
|
|
#Configure Webmail
|
|
mkdir -p /opt/webmail/data/_data_/_default_/configs /opt/webmail/data/_data_/_default_/domains
|
|
touch /opt/webmail/data/_data_/_default_/domains/disabled
|
|
mv Configs/SnappyMail-application.ini /opt/webmail/data/_data_/_default_/configs/application.ini
|
|
mv Configs/SnappyMail-Domain-localhost.ini /opt/webmail/data/_data_/_default_/domains/localhost.ini
|
|
chown -R nginx:nginx /opt/webmail
|
|
find /opt/webmail -type d -exec chmod 755 {} \;
|
|
find /opt/webmail -type f -exec chmod 644 {} \;
|
|
|
|
#Install OfflineIMAP3
|
|
mkdir /opt/OfflineIMAP3
|
|
tar -C /opt/OfflineIMAP3 -xzf /tmp/olim3.tar.gz --strip 1
|
|
sed -i '/kerberos/c\' /opt/OfflineIMAP3/requirements.txt
|
|
sed -i '/cygwin/c\' /opt/OfflineIMAP3/requirements.txt
|
|
pip3 install -r /opt/OfflineIMAP3/requirements.txt
|
|
|
|
#Add OfflineIMAP config to user skeleton folder
|
|
mkdir /etc/skel
|
|
mv Configs/offlineimaprc /etc/skel/.offlineimaprc
|
|
touch /opt/mailsync.sh
|
|
echo '30 2 * * 4 ash /opt/mailsync.sh > /dev/null' >> /etc/crontabs/root
|
|
|
|
#Add tool update scripts
|
|
mv Resources/UpdateSnappyMail.sh /opt/UpdateSnappyMail.sh
|
|
mv Resources/UpdateOfflineImap3.sh /opt/UpdateOfflineImap3.sh
|
|
mv Resources/AddMailBox.sh /opt/AddMailBox.sh
|
|
#Cleanup
|
|
rm -f /tmp/olim3.tar.gz /tmp/smc.tar.gz
|
|
#Start and enable service
|
|
rc-update add dovecot
|
|
rc-update add nginx
|
|
rc-update add php-fpm8
|
|
|
|
if [ -z ${DistoBuilderINT+x} ]; then
|
|
service dovecot start
|
|
service nginx start
|
|
service php-fpm8 start
|
|
fi |