From b2653d82830b90512206d5ef7e2973af18e2400d Mon Sep 17 00:00:00 2001 From: neodarz Date: Wed, 2 Aug 2017 01:13:11 +0200 Subject: initial commit --- create_apache_conf.sh | 96 +++++++++++++++++++++++++++++++++++++++++++++++++++ create_service.sh | 40 +++++++++++++++++++++ install.sh | 16 +++++++++ install_weboob.sh | 5 +++ list.sh | 1 + new_kresus.sh | 19 ++++++++++ test_passwd.sh | 4 +++ uninstall.sh | 21 +++++++++++ 8 files changed, 202 insertions(+) create mode 100755 create_apache_conf.sh create mode 100755 create_service.sh create mode 100755 install.sh create mode 100755 install_weboob.sh create mode 100755 list.sh create mode 100755 new_kresus.sh create mode 100755 test_passwd.sh create mode 100755 uninstall.sh diff --git a/create_apache_conf.sh b/create_apache_conf.sh new file mode 100755 index 0000000..28c7769 --- /dev/null +++ b/create_apache_conf.sh @@ -0,0 +1,96 @@ + +usage () { + echo "You must set a $1 !" + echo "Usage:" + echo " create_apache_conf.sh " + exit 0 +} + +if [ -z $1 ]; then + usage "USER" +fi + + +USER=$1 + +cat > /etc/apache2/sites-available/$USER.kresus.neodarz.net.conf << EOF + + ServerName $USER.kresus.neodarz.net + ServerAdmin me@example.net + + #Alias /.well-known/acme-challenge /tmp/.well-known/acme-challenge + + + Options None + AllowOverride None + + Require all granted + AddDefaultCharset off + + AuthType None + Satisfy any + + + Redirect permanent / https://$USER.kresus.neodarz.net/ + + ErrorLog /home/website/kresus-gen/logs/error.log + CustomLog /home/website/kresus-gen/logs/access.log combined + +EOF + +cat > /etc/apache2/sites-available/$USER.kresus.neodarz.net-le-ssl.conf << EOF + + + ServerName $USER.kresus.neodarz.net + ServerAdmin me@example.net + + ProxyPass "/" "http://127.0.0.1:9876/" + ProxyPassReverse "/" "http://127.0.0.1:9876/" + + Alias /.well-known/acme-challenge /tmp/.well-known/acme-challenge + + + Options None + AllowOverride None + + Require all granted + AddDefaultCharset off + + AuthType None + Satisfy any + + + + AuthUserFile /home/website/kresus-gen/$USER.kresus.neodarz.net/.htpasswd + AuthName "Authentification" + AuthType Basic + Require valid-user + + + SSLEngine on + + SSLCertificateKeyFile /etc/letsencrypt/live/$USER.kresus.neodarz.net/privkey.pem + SSLCertificateFile /etc/letsencrypt/live/$USER.kresus.neodarz.net/fullchain.pem + + Header always set Strict-Transport-Security "max-age=15768000" + + + SSLOptions +StdEnvVars + + + SSLOptions +StdEnvVars + + + ErrorLog /home/website/kresus-gen/logs/error.log + CustomLog /home/website/kresus-gen/logs/access.log combined + + + +# vim: syntax=apache ts=4 sw=4 sts=4 sr noet +EOF + +certbot --apache -d $USER.kresus.neodarz.net + +a2ensite $USER.kresus.neodarz.net +systemctl reload apache2 + diff --git a/create_service.sh b/create_service.sh new file mode 100755 index 0000000..549230b --- /dev/null +++ b/create_service.sh @@ -0,0 +1,40 @@ +usage () { + echo "You must set a $1 !" + echo "Usage:" + echo " create-service.sh " + exit 0 +} + +if [ -z $1 ]; then + usage "USER" +fi + + +USER=$1 +NODE_PATH=$(which node) + +sudo bash -c "cat << EOF > /etc/systemd/system/kresus-$USER.service +[Unit] +Description=Personal finance manager +After=network.target + +[Service] +WorkingDirectory=/home/website/kresus-gen/$USER.kresus.neodarz.net +Environment=NODE_ENV=production +ExecStart=$NODE_PATH bin/kresus.js + +Type=simple +#Restart=always + +User=neodarz + +StandardOutput=journal +StandardError=inherit +SyslogIdentifier=kresus + +[Install] +WantedBy=multi-user.target +EOF" + +sudo systemctl enable kresus-$USER.service +sudo systemctl start kresus-$USER.service diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..fc032a8 --- /dev/null +++ b/install.sh @@ -0,0 +1,16 @@ +usage () { + echo "You must set a $1 !" + echo "Usage:" + echo " install.sh " + exit 0 +} + +if [ -z $1 ]; then + usage "USER" +elif [ -z $2 ]; then + usage "PASSWORD" +fi + +./new_kresus.sh $1 $2 +./create_service.sh $1 +sudo ./create_apache_conf.sh $1 diff --git a/install_weboob.sh b/install_weboob.sh new file mode 100755 index 0000000..c891655 --- /dev/null +++ b/install_weboob.sh @@ -0,0 +1,5 @@ +wget http://ftp.fr.debian.org/debian/pool/main/w/weboob/weboob_1.2-1_all.deb +wget http://ftp.fr.debian.org/debian/pool/main/w/weboob/python-weboob_1.2-1_all.deb +sudo dpkg -i python-weboob_1.2-1_all.deb +sudo dpkg -i weboob_1.2-1_all.deb +rm python-weboob_1.2-1_all.deb weboob_1.2-1_all.deb diff --git a/list.sh b/list.sh new file mode 100755 index 0000000..81b4bd3 --- /dev/null +++ b/list.sh @@ -0,0 +1 @@ +ls . | grep -e 'kresus.neodarz.net' diff --git a/new_kresus.sh b/new_kresus.sh new file mode 100755 index 0000000..90d281c --- /dev/null +++ b/new_kresus.sh @@ -0,0 +1,19 @@ +usage () { + echo "You must set a $1 !" + echo "Usage:" + echo " new_kresus.sh " + exit 0 +} + +if [ -z $1 ]; then + usage "USER" +elif [ -z $2 ]; then + usage "PASSWORD" +fi + + +USER=$1 +PASS=$2 +git clone https://framagit.org/bnjbvr/kresus.git $USER.kresus.neodarz.net +cd $USER.kresus.neodarz.net; npm install; npm install leveldown@1.5.0; ./scripts/build.sh +htpasswd -Bb -c .htpasswd $USER $PASS diff --git a/test_passwd.sh b/test_passwd.sh new file mode 100755 index 0000000..881adfc --- /dev/null +++ b/test_passwd.sh @@ -0,0 +1,4 @@ +if [ -z $1 ]; then + break + echo "error $1" +fi diff --git a/uninstall.sh b/uninstall.sh new file mode 100755 index 0000000..5a6f7f3 --- /dev/null +++ b/uninstall.sh @@ -0,0 +1,21 @@ +usage () { + echo "You must set a $1 !" + echo "Usage:" + echo " uninstall.sh " + exit 0 +} + +if [ -z $1 ]; then + usage "USER" +fi + + +USER=$1 + +sudo systemctl stop kresus-$USER.service +sudo rm /etc/systemd/system/kresus-$USER.service +sudo a2dissite $USER.kresus.neodarz.net.conf +sudo a2dissite $USER.kresus.neodarz.net-le-ssl.conf +sudo rm /etc/apache2/sites-available/$USER.kresus.neodarz.net.conf +sudo rm /etc/apache2/sites-available/$USER.kresus.neodarz.net-le-ssl.conf +sudo systemctl reload apache2.service -- cgit v1.2.1