aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xcreate_apache_conf.sh96
-rwxr-xr-xcreate_service.sh40
-rwxr-xr-xinstall.sh16
-rwxr-xr-xinstall_weboob.sh5
-rwxr-xr-xlist.sh1
-rwxr-xr-xnew_kresus.sh19
-rwxr-xr-xtest_passwd.sh4
-rwxr-xr-xuninstall.sh21
8 files changed, 202 insertions, 0 deletions
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 <user>"
+ exit 0
+}
+
+if [ -z $1 ]; then
+ usage "USER"
+fi
+
+
+USER=$1
+
+cat > /etc/apache2/sites-available/$USER.kresus.neodarz.net.conf << EOF
+<VirtualHost *:80>
+ ServerName $USER.kresus.neodarz.net
+ ServerAdmin me@example.net
+
+ #Alias /.well-known/acme-challenge /tmp/.well-known/acme-challenge
+
+ <Directory /tmp/.well-known/acme-challenge>
+ Options None
+ AllowOverride None
+
+ Require all granted
+ AddDefaultCharset off
+
+ AuthType None
+ Satisfy any
+ </Directory>
+
+ Redirect permanent / https://$USER.kresus.neodarz.net/
+
+ ErrorLog /home/website/kresus-gen/logs/error.log
+ CustomLog /home/website/kresus-gen/logs/access.log combined
+</VirtualHost>
+EOF
+
+cat > /etc/apache2/sites-available/$USER.kresus.neodarz.net-le-ssl.conf << EOF
+<IfModule mod_ssl.c>
+ <VirtualHost *:443>
+ 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
+
+ <Directory /tmp/.well-known/acme-challenge>
+ Options None
+ AllowOverride None
+
+ Require all granted
+ AddDefaultCharset off
+
+ AuthType None
+ Satisfy any
+ </Directory>
+
+ <Location />
+ AuthUserFile /home/website/kresus-gen/$USER.kresus.neodarz.net/.htpasswd
+ AuthName "Authentification"
+ AuthType Basic
+ Require valid-user
+ </Location>
+
+ 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"
+
+ <FilesMatch "\.(cgi|shtml|phtml|php)$">
+ SSLOptions +StdEnvVars
+ </FilesMatch>
+ <Directory /usr/lib/cgi-bin>
+ SSLOptions +StdEnvVars
+ </Directory>
+
+ ErrorLog /home/website/kresus-gen/logs/error.log
+ CustomLog /home/website/kresus-gen/logs/access.log combined
+ </VirtualHost>
+</IfModule>
+
+# 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 <user>"
+ 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 <user> <password>"
+ 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 <user> <password>"
+ 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 <user>"
+ 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