From 0240e956210aecb1b811e55ea508d64f2b03132f Mon Sep 17 00:00:00 2001 From: Disassembler Date: Sun, 16 Sep 2018 17:19:13 +0200 Subject: [PATCH] Use py-bcrypt instead of invoking container --- kanboard/setup.sh | 2 +- sigmah/setup.sh | 5 +---- ushahidi/setup.sh | 3 +-- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/kanboard/setup.sh b/kanboard/setup.sh index 87d8a7d..622ff49 100755 --- a/kanboard/setup.sh +++ b/kanboard/setup.sh @@ -17,7 +17,7 @@ chown -R 8009:8009 /srv/kanboard/data envsubst <${SOURCE_DIR}/srv/kanboard/conf/config.php >/srv/kanboard/conf/config.php export KANBOARD_ADMIN_USER=admin export KANBOARD_ADMIN_PWD=$(head -c 12 /dev/urandom | base64) -export KANBOARD_ADMIN_HASH=$(lxc-execute kanboard -- php -r "echo password_hash('${KANBOARD_ADMIN_PWD}', PASSWORD_BCRYPT);") +export KANBOARD_ADMIN_HASH=$(python3 -c "import bcrypt; print(bcrypt.hashpw('${KANBOARD_ADMIN_PWD}'.encode(), bcrypt.gensalt()).decode().replace('2b', '2y'))") envsubst <${SOURCE_DIR}/adminpwd.sql | lxc-attach -u 5432 -g 5432 postgres -- psql kanboard vmmgr update-login kanboard "${KANBOARD_ADMIN_USER}" "${KANBOARD_ADMIN_PWD}" diff --git a/sigmah/setup.sh b/sigmah/setup.sh index 0fc1de2..043f866 100755 --- a/sigmah/setup.sh +++ b/sigmah/setup.sh @@ -23,10 +23,7 @@ wget https://github.com/sigmah-dev/sigmah/releases/download/v2.0.2/sigmah-newOrg export SIGMAH_ADMIN_USER=Admin export SIGMAH_ADMIN_EMAIL=admin@example.com export SIGMAH_ADMIN_PWD=$(head -c 12 /dev/urandom | base64) -# TODO: python-bcrypt -apk --no-cache add apache2-utils -export SIGMAH_ADMIN_HASH=$(htpasswd -bnBC 10 "" ${SIGMAH_ADMIN_PWD} | tr -d ':\n' | sed 's/$2y/$2a/') -apk --no-cache del apache2-utils +export SIGMAH_ADMIN_HASH=$(python3 -c "import bcrypt; print(bcrypt.hashpw('${SIGMAH_ADMIN_PWD}'.encode(), bcrypt.gensalt(prefix=b'2a')).decode())") sed -i "s|§OrganizationName§|Demo organization|g" /tmp/sigmah-newOrganizationLaunchScript.sql sed -i "s|§OrganizationLogoFilename§|logo.png|g" /tmp/sigmah-newOrganizationLaunchScript.sql sed -i "s|§HeadquartersCountryCode§|CZ|g" /tmp/sigmah-newOrganizationLaunchScript.sql diff --git a/ushahidi/setup.sh b/ushahidi/setup.sh index 31af903..2748c78 100755 --- a/ushahidi/setup.sh +++ b/ushahidi/setup.sh @@ -22,8 +22,7 @@ lxc-execute ushahidi -- /srv/ushahidi/platform/bin/phinx migrate -c /srv/ushahid # Create admin account export USHAHIDI_ADMIN_USER=admin@example.com export USHAHIDI_ADMIN_PWD=$(head -c 12 /dev/urandom | base64) -#TODO: python-bcrypt -export USHAHIDI_ADMIN_HASH=$(lxc-execute ushahidi -- php -r "echo password_hash('${USHAHIDI_ADMIN_PWD}', PASSWORD_BCRYPT);") +export USHAHIDI_ADMIN_HASH=$(python3 -c "import bcrypt; print(bcrypt.hashpw('${USHAHIDI_ADMIN_PWD}'.encode(), bcrypt.gensalt()).decode().replace('2b', '2y'))") envsubst <${SOURCE_DIR}/adminpwd.sql | lxc-attach mariadb -- mysql ushahidi vmmgr update-login ushahidi "${USHAHIDI_ADMIN_USER}" "${USHAHIDI_ADMIN_PWD}"