mirror of
https://github.com/YunoHost-Apps/dotclear2_ynh.git
synced 2024-09-03 18:26:29 +02:00
DB password generation left to yunohost initdb, timezone from server, and cosmetic stuff
This commit is contained in:
parent
5826625189
commit
91ff4a2414
1 changed files with 20 additions and 12 deletions
|
@ -1,7 +1,6 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# DotClear 2 installation script for YunoHost
|
# DotClear 2 installation script for YunoHost
|
||||||
|
|
||||||
# First arguments
|
|
||||||
app=dotclear2
|
app=dotclear2
|
||||||
domain=$1
|
domain=$1
|
||||||
path=$2
|
path=$2
|
||||||
|
@ -9,31 +8,40 @@ path=$2
|
||||||
# Check domain/path availability asap
|
# Check domain/path availability asap
|
||||||
sudo yunohost app checkurl $domain$path -a $app
|
sudo yunohost app checkurl $domain$path -a $app
|
||||||
if [[ ! $? -eq 0 ]]; then
|
if [[ ! $? -eq 0 ]]; then
|
||||||
|
echo "This $domain$path is already in use, installation canceled"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Other arguments
|
|
||||||
admin=$3
|
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
|
is_public=$5
|
||||||
directory=/var/www/$app/
|
directory=/var/www/$app/
|
||||||
php_config="$directory/inc/config.php"
|
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'`
|
||||||
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'`
|
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'`
|
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'`
|
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
|
# Save app settings
|
||||||
sudo yunohost app setting $app admin -v "$admin"
|
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"
|
sudo yunohost app setting $app is_public -v "$is_public"
|
||||||
|
|
||||||
|
|
||||||
# Make sure we got the tools we need for this install
|
# Make sure we got the tools we need for this install
|
||||||
sudo apt install -y curl wget sed
|
sudo apt install -y curl wget sed
|
||||||
|
|
||||||
# Initialize database and store mysql password for upgrade
|
# 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
|
sudo yunohost app setting $app mysqlpwd -v $db_password
|
||||||
|
|
||||||
# Get sources
|
# Get sources
|
||||||
|
@ -73,15 +81,15 @@ sudo service nginx reload
|
||||||
sudo yunohost app ssowatconf
|
sudo yunohost app ssowatconf
|
||||||
|
|
||||||
# Setting first user details and filling database calling admin/install/index.php
|
# 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
|
# Success or not success
|
||||||
if [ `echo $success | grep -c success` -ge 0 ]
|
if [ `echo $success | grep -c success` -ge 0 ]
|
||||||
then
|
then
|
||||||
echo Installation OK, $app should be available here $domain$path/
|
echo Installation OK, $app should be available here https://$domain$path/
|
||||||
exit 0
|
exit 0
|
||||||
else
|
else
|
||||||
echo Using curl to finish setup failed, open $domain$path/admin/install/index.php and do it yourself
|
echo Using curl to finish setup failed, open https://$domain$path/admin/install/index.php and do it yourself
|
||||||
exit 1
|
exit 10
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue