conf_server/install_pywallter.sh

84 lines
2.6 KiB
Bash
Executable File

#!/bin/sh
. ./myserver.conf
install_pywallter_pkg(){
pkg_add py3-werkzeug py3-jinja2 py3-Pillow py3-wtforms py3-flask-wtf py3-flask \
py3-bcrypt py3-markdown py3-gevent py3-zopeinterface py3-pip
pip install flask-bcrypt
}
install_pywallter_app(){
orig_path=`pwd`
useradd -s /sbin/nologin -d /home/pywallter -m pywallter;
cd /home/pywallter;
su -m pywallter -c "git clone https://kitoy.me/git/kitoy/pywallter"
cp -v ./pywallter/scripts/set_mail_alias /usr/local/bin/
cp -v ./pywallter/scripts/set_mail_passwd /usr/local/bin/
touch /etc/mail/reserved
cd $orig_path
}
gen_pywallter_configuration_app(){
cat > my_configuration/pywallter/config.py <<EOF
BASE_URL="https://$pywallter_domain/"
SECRET_KEY="$pywallter_secret_key"
DOSSIER_APP = "./users/"
DATABASE = "./base.db"
EXT_IMG= {'.jpg', '.JPG', '.png', '.PNG', '.gif', '.GIF', '.bmp', '.BMP', '.jpeg', '.JPEG' }
SIGNIN_ENABLE = True
SETUID='doas'
EOF
if [ SERVICE_MAIL = "yes" ];
then
echo "MAIL_SERVER = True" >> my_configuration/pywallter/config.py
else
echo "MAIL_SERVER = False" >> my_configuration/pywallter/config.py
fi
if [ SERVICE_XMPP = "yes" ];
then
echo "XMPP_SERVER = True" >> my_configuration/pywallter/config.py
else
echo "XMPP_SERVER = False" >> myconfiguration/pywallter/config.py
fi
}
gen_nginx_pywallter_app(){
cp -v default_configuration/pywallter/nginx.conf.sample my_configuration/pywallter/nginx.conf
sed -i "s/__pywallter_domain__/$pywallter_domain/g" my_configuration/pywallter/nginx.conf
}
install_pywallter_configuration_files(){
cp -v my_configuration/pywallter/config.py /home/pywallter/pywallter/
cp -v /home/pywallter/pywallter/scripts/etc/mailconfig /etc/
cp -v my_configuration/pywallter/nginx.conf /etc/nginx/sites-available/$pywallter_domain
ln -s /etc/nginx/sites-available/$pywallter_domain /etc/nginx/sites-enabled/$pywallter_domain
cp -v default_configuration/pywallter/pywallter.rc /etc/rc.d/pywallter
cp -v /etc/doas.conf /etc/doas.conf.old
egrep -v "pywallter" /etc/doas.conf > /tmp/doas.conf
cat >> /tmp/doas.conf <<EOF
permit nopass pywallter as root cmd set_mail_alias
permit nopass pywallter as root cmd set_mail_passwd
permit nopass pywallter as root cmd prosodyctl
EOF
mv /tmp/doas.conf /etc/doas/conf
}
mkdir my_configuration/pywallter/
if [ "$1" == "gen-config-only" ];
then
gen_pywallter_configuration_app
gen_nginx_pywallter_app
elif [ "$1" == "install" ];
then
gen_pywallter_configuration_app
gen_nginx_pywallter_app
install_pywallter_app
install_pywallter_configuration_files
fi