From 01844d86e0d4e066743ff2f0b6dd1ac6e5230fb6 Mon Sep 17 00:00:00 2001 From: Guillaume Vincent Date: Sun, 9 Apr 2017 20:03:49 +0200 Subject: [PATCH] move scripts in scripts folder and improve lesspass.sh script --- backup_db.sh | 7 ------- cli | 2 +- deploy.sh | 11 ----------- desktop | 2 +- dev-utils.sh | 40 ---------------------------------------- frontend | 2 +- lesspass.sh | 5 ++++- pure | 2 +- readme.md | 2 +- restore_db.sh | 13 ------------- scripts/backup_db.sh | 7 +++++++ scripts/deploy.sh | 11 +++++++++++ scripts/dev-utils.sh | 40 ++++++++++++++++++++++++++++++++++++++++ scripts/restore_db.sh | 13 +++++++++++++ scripts/send_archive.sh | 13 +++++++++++++ send_archive.sh | 13 ------------- 16 files changed, 93 insertions(+), 90 deletions(-) delete mode 100755 backup_db.sh delete mode 100755 deploy.sh delete mode 100755 dev-utils.sh delete mode 100755 restore_db.sh create mode 100755 scripts/backup_db.sh create mode 100755 scripts/deploy.sh create mode 100755 scripts/dev-utils.sh create mode 100755 scripts/restore_db.sh create mode 100755 scripts/send_archive.sh delete mode 100755 send_archive.sh diff --git a/backup_db.sh b/backup_db.sh deleted file mode 100755 index aa2aea6..0000000 --- a/backup_db.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash -NOW=$(date +"%Y%m%dT%H%M%SZ") -DUMP_FILENAME="$NOW"_lesspass_db.sql -docker exec -it lesspass_db_1 sh -c 'PGPASSWORD=$POSTGRES_PASSWORD pg_dumpall -U $POSTGRES_USER -h localhost -p 5432 --clean --file='$DUMP_FILENAME'' -docker cp lesspass_db_1:$DUMP_FILENAME . -docker exec -it lesspass_db_1 rm $DUMP_FILENAME -echo $DUMP_FILENAME \ No newline at end of file diff --git a/cli b/cli index 2d01dd1..c542cf4 160000 --- a/cli +++ b/cli @@ -1 +1 @@ -Subproject commit 2d01dd16b12f455ac699b4b8e5b38779cbec44f3 +Subproject commit c542cf45b726dd3a7438c017524d1f8a8d12d04c diff --git a/deploy.sh b/deploy.sh deleted file mode 100755 index 22a6f55..0000000 --- a/deploy.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash - -export COMPOSE_HTTP_TIMEOUT=600 - -# pull new images -docker-compose pull - -# restart container -docker-compose down -docker-compose up -d -docker images --quiet --filter=dangling=true | xargs --no-run-if-empty docker rmi diff --git a/desktop b/desktop index 4fd1ca3..98bb4ba 160000 --- a/desktop +++ b/desktop @@ -1 +1 @@ -Subproject commit 4fd1ca3fc6b73d97bce85cf3815ac3830ceb798a +Subproject commit 98bb4ba17836156d47299debfdedf0e8a95e01ac diff --git a/dev-utils.sh b/dev-utils.sh deleted file mode 100755 index b0692b5..0000000 --- a/dev-utils.sh +++ /dev/null @@ -1,40 +0,0 @@ -#!/usr/bin/env bash - -function cmd { - npm install --save lesspass-pure@4.5.0 - npm run build - git add . - git status - git commit -m 'add lesspass-pure version 4.5.0' - git push --tags origin master -} - -#submodules="cli cordova core cozy desktop frontend pure webextension" -#submodules="backend cli cordova core cozy desktop frontend nginx pure sandbox snap webextension" -submodules="cordova cozy desktop frontend webextension" -for submodule in ${submodules} -do - cd $submodule - cmd - cd .. -done - -#VERSION=2.4.0 -#cd webextension -#git archive -o webextension.zip master -#mv webextension.zip /tmp -#cd ../pure/ -#git archive -o pure.zip master -#mv pure.zip /tmp -#cd /tmp -#mkdir LessPass -#mv pure.zip LessPass/ -#mv webextension.zip LessPass/ -#cd LessPass/ -#unzip pure.zip -d pure -#unzip webextension.zip -d webextension -#rm pure.zip webextension.zip -#zip -r LessPass-src-v$VERSION.zip pure webextension -#mv LessPass-src-v$VERSION.zip ~/Desktop/ -#cd ~/Desktop/ -#rm -rf /tmp/LessPass diff --git a/frontend b/frontend index e795967..45542cc 160000 --- a/frontend +++ b/frontend @@ -1 +1 @@ -Subproject commit e79596709c3245f44491cc8de7be06c0b32a1450 +Subproject commit 45542cc4d558f3a4d4c279d6f4dadea9c846c9a7 diff --git a/lesspass.sh b/lesspass.sh index 78313cb..54f76d3 100755 --- a/lesspass.sh +++ b/lesspass.sh @@ -19,7 +19,7 @@ if [ "$#" -eq "1" ] then DOMAIN=$1 else - echo "Please enter your domain name: " + echo "Please enter your domain name (e.g. example.org): " read DOMAIN fi @@ -37,3 +37,6 @@ docker-compose pull # restart container docker-compose down docker-compose up -d + +echo "LessPass Database is now running on $DOMAIN" +echo "If you want to configure an email server for your LessPass Database see: https://github.com/lesspass/lesspass#configure-email" diff --git a/pure b/pure index fc21a06..16c7b6b 160000 --- a/pure +++ b/pure @@ -1 +1 @@ -Subproject commit fc21a0612f1300fa383d84fa65d1fab84a1a23f5 +Subproject commit 16c7b6bc35960ad34a4e3e53bcb6e1f2ba873779 diff --git a/readme.md b/readme.md index 065071c..e4ce94d 100644 --- a/readme.md +++ b/readme.md @@ -37,7 +37,7 @@ simply run bash <(curl -s https://raw.githubusercontent.com/lesspass/lesspass/master/lesspass.sh) [DOMAIN] -You can specify your domain (e.g. example.com). If not provided, you'll be asked to enter it. +You can specify your domain (e.g. example.org). If not provided, you'll be asked to enter it. ### configure email diff --git a/restore_db.sh b/restore_db.sh deleted file mode 100755 index 7a5ef80..0000000 --- a/restore_db.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash -if [ -z $1 ]; then - echo "No dump provided. Usage: $0 201..._lesspass_db.sql" - exit 1 -fi - -DUMP_FILENAME=$1 - -docker cp $DUMP_FILENAME lesspass_db_1:$DUMP_FILENAME -docker exec -it lesspass_db_1 sh -c 'PGPASSWORD=$POSTGRES_PASSWORD dropdb -U $POSTGRES_USER $POSTGRES_DB' -docker exec -it lesspass_db_1 sh -c 'PGPASSWORD=$POSTGRES_PASSWORD createdb -U $POSTGRES_USER $POSTGRES_DB' -docker exec -it lesspass_db_1 sh -c 'PGPASSWORD=$POSTGRES_PASSWORD psql -U $POSTGRES_USER -h localhost -p 5432 < '$DUMP_FILENAME'' -docker exec -it lesspass_db_1 rm $DUMP_FILENAME diff --git a/scripts/backup_db.sh b/scripts/backup_db.sh new file mode 100755 index 0000000..aa2aea6 --- /dev/null +++ b/scripts/backup_db.sh @@ -0,0 +1,7 @@ +#!/bin/bash +NOW=$(date +"%Y%m%dT%H%M%SZ") +DUMP_FILENAME="$NOW"_lesspass_db.sql +docker exec -it lesspass_db_1 sh -c 'PGPASSWORD=$POSTGRES_PASSWORD pg_dumpall -U $POSTGRES_USER -h localhost -p 5432 --clean --file='$DUMP_FILENAME'' +docker cp lesspass_db_1:$DUMP_FILENAME . +docker exec -it lesspass_db_1 rm $DUMP_FILENAME +echo $DUMP_FILENAME \ No newline at end of file diff --git a/scripts/deploy.sh b/scripts/deploy.sh new file mode 100755 index 0000000..22a6f55 --- /dev/null +++ b/scripts/deploy.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +export COMPOSE_HTTP_TIMEOUT=600 + +# pull new images +docker-compose pull + +# restart container +docker-compose down +docker-compose up -d +docker images --quiet --filter=dangling=true | xargs --no-run-if-empty docker rmi diff --git a/scripts/dev-utils.sh b/scripts/dev-utils.sh new file mode 100755 index 0000000..b0692b5 --- /dev/null +++ b/scripts/dev-utils.sh @@ -0,0 +1,40 @@ +#!/usr/bin/env bash + +function cmd { + npm install --save lesspass-pure@4.5.0 + npm run build + git add . + git status + git commit -m 'add lesspass-pure version 4.5.0' + git push --tags origin master +} + +#submodules="cli cordova core cozy desktop frontend pure webextension" +#submodules="backend cli cordova core cozy desktop frontend nginx pure sandbox snap webextension" +submodules="cordova cozy desktop frontend webextension" +for submodule in ${submodules} +do + cd $submodule + cmd + cd .. +done + +#VERSION=2.4.0 +#cd webextension +#git archive -o webextension.zip master +#mv webextension.zip /tmp +#cd ../pure/ +#git archive -o pure.zip master +#mv pure.zip /tmp +#cd /tmp +#mkdir LessPass +#mv pure.zip LessPass/ +#mv webextension.zip LessPass/ +#cd LessPass/ +#unzip pure.zip -d pure +#unzip webextension.zip -d webextension +#rm pure.zip webextension.zip +#zip -r LessPass-src-v$VERSION.zip pure webextension +#mv LessPass-src-v$VERSION.zip ~/Desktop/ +#cd ~/Desktop/ +#rm -rf /tmp/LessPass diff --git a/scripts/restore_db.sh b/scripts/restore_db.sh new file mode 100755 index 0000000..7a5ef80 --- /dev/null +++ b/scripts/restore_db.sh @@ -0,0 +1,13 @@ +#!/bin/bash +if [ -z $1 ]; then + echo "No dump provided. Usage: $0 201..._lesspass_db.sql" + exit 1 +fi + +DUMP_FILENAME=$1 + +docker cp $DUMP_FILENAME lesspass_db_1:$DUMP_FILENAME +docker exec -it lesspass_db_1 sh -c 'PGPASSWORD=$POSTGRES_PASSWORD dropdb -U $POSTGRES_USER $POSTGRES_DB' +docker exec -it lesspass_db_1 sh -c 'PGPASSWORD=$POSTGRES_PASSWORD createdb -U $POSTGRES_USER $POSTGRES_DB' +docker exec -it lesspass_db_1 sh -c 'PGPASSWORD=$POSTGRES_PASSWORD psql -U $POSTGRES_USER -h localhost -p 5432 < '$DUMP_FILENAME'' +docker exec -it lesspass_db_1 rm $DUMP_FILENAME diff --git a/scripts/send_archive.sh b/scripts/send_archive.sh new file mode 100755 index 0000000..37f72db --- /dev/null +++ b/scripts/send_archive.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +echo "Usage: ./send_archive.sh [USER@HOSTNAME] [SSH_PORT]" + +HOST="${1:-admin@lesspass.com}" +SSH_PORT="${2:-22}" + +ssh -p $SSH_PORT $HOST 'mkdir -p ~/lesspass' +scp -P $SSH_PORT docker-compose.prod.yml "$HOST":~/ +scp -P $SSH_PORT deploy.sh "$HOST":~/lesspass +scp -P $SSH_PORT backup_db.sh "$HOST":~/backups +scp -P $SSH_PORT restore_db.sh "$HOST":~/backups +ssh -p $SSH_PORT $HOST 'mv docker-compose.prod.yml ~/lesspass/docker-compose.yml' diff --git a/send_archive.sh b/send_archive.sh deleted file mode 100755 index 37f72db..0000000 --- a/send_archive.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash - -echo "Usage: ./send_archive.sh [USER@HOSTNAME] [SSH_PORT]" - -HOST="${1:-admin@lesspass.com}" -SSH_PORT="${2:-22}" - -ssh -p $SSH_PORT $HOST 'mkdir -p ~/lesspass' -scp -P $SSH_PORT docker-compose.prod.yml "$HOST":~/ -scp -P $SSH_PORT deploy.sh "$HOST":~/lesspass -scp -P $SSH_PORT backup_db.sh "$HOST":~/backups -scp -P $SSH_PORT restore_db.sh "$HOST":~/backups -ssh -p $SSH_PORT $HOST 'mv docker-compose.prod.yml ~/lesspass/docker-compose.yml'