From 91ff4a24140c4bf5672bb2cf6a880ef0d52a0f3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Garrigue?= Date: Thu, 20 Aug 2015 14:29:29 +0000 Subject: [PATCH] DB password generation left to yunohost initdb, timezone from server, and cosmetic stuff --- scripts/install | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/scripts/install b/scripts/install index 7dec5b5..3d74dc9 100755 --- a/scripts/install +++ b/scripts/install @@ -1,7 +1,6 @@ #!/bin/bash # DotClear 2 installation script for YunoHost -# First arguments app=dotclear2 domain=$1 path=$2 @@ -9,31 +8,40 @@ path=$2 # Check domain/path availability asap sudo yunohost app checkurl $domain$path -a $app if [[ ! $? -eq 0 ]]; then + echo "This $domain$path is already in use, installation canceled" exit 1 fi -# Other arguments admin=$3 -password=$4 + +# Check that given user is an existing yunohost user +sudo yunohost user list | grep username | cut -d' ' -f6 | grep $admin +if [[ ! $? -eq 1 ]]; then + echo "I can't find user '$admin' in yunohost's username list, installation canceled" + exit 2 +fi + +admin_password=$4 is_public=$5 directory=/var/www/$app/ -php_config="$directory/inc/config.php" -db_password="$(dd if=/dev/urandom bs=1 count=200 2> /dev/null | tr -c -d '[A-Za-z0-9]' | sed -n 's/\(.\{24\}\).*/\1/p')" -master_key=$(dd if=/dev/urandom bs=1 count=200 2> /dev/null | tr -c -d '[A-Za-z0-9]' | sed -n 's/\(.\{24\}\).*/\1/p') +php_config=$directory/inc/config.php +master_key=`dd if=/dev/urandom bs=1 count=200 2> /dev/null | tr -c -d '[A-Za-z0-9]' | sed -n 's/\(.\{24\}\).*/\1/p'` firstname=`sudo yunohost user info $admin | grep firstname | cut -d' ' -f2 | tr -d '\n'` lastname=`sudo yunohost user info $admin | grep lastname | cut -d' ' -f2 | tr -d '\n'` email=`sudo yunohost user info $admin | grep mail | cut -d' ' -f2 | tr -d '\n'` -TZ=`cat /etc/timezone|tr -d '\n'` +TZ=`cat /etc/timezone | tr -d '\n'` # Save app settings sudo yunohost app setting $app admin -v "$admin" +sudo yunohost app setting $app admin_password -v "$admin_password" sudo yunohost app setting $app is_public -v "$is_public" + # Make sure we got the tools we need for this install sudo apt install -y curl wget sed # Initialize database and store mysql password for upgrade -sudo yunohost app initdb $app -p $db_password +db_password=`sudo yunohost app initdb $app | tr -d '\n'` sudo yunohost app setting $app mysqlpwd -v $db_password # Get sources @@ -73,15 +81,15 @@ sudo service nginx reload sudo yunohost app ssowatconf # Setting first user details and filling database calling admin/install/index.php -success=`curl -F "u_email=$EMAIL" -F "u_firstname=$FIRSTNAME" -F "u_name=$NAME" -F "u_login=$LOGIN" -F "u_pwd=$PWD" -F "u_pwd2=$PWD" -F "u_date=$TZ" $domain$path/admin/install/index.php` +success=`curl -F "u_email=$EMAIL" -F "u_firstname=$FIRSTNAME" -F "u_name=$NAME" -F "u_login=$LOGIN" -F "u_pwd=$admin_password" -F "u_pwd2=$admin_password" -F "u_date=$TZ" https://$domain$path/admin/install/index.php` # Success or not success if [ `echo $success | grep -c success` -ge 0 ] then - echo Installation OK, $app should be available here $domain$path/ + echo Installation OK, $app should be available here https://$domain$path/ exit 0 else - echo Using curl to finish setup failed, open $domain$path/admin/install/index.php and do it yourself - exit 1 + echo Using curl to finish setup failed, open https://$domain$path/admin/install/index.php and do it yourself + exit 10 fi