2015-08-20 12:20:05 +02:00
|
|
|
#!/bin/bash
|
|
|
|
# DotClear 2 installation script for YunoHost
|
|
|
|
|
2019-01-04 18:28:10 +01:00
|
|
|
app=$YNH_APP_INSTANCE_NAME
|
|
|
|
domain=$YNH_APP_ARG_DOMAIN
|
2019-01-04 18:33:38 +01:00
|
|
|
path=$YNH_APP_ARG_PATH
|
2015-08-19 17:41:15 +02:00
|
|
|
|
2015-08-20 12:20:05 +02:00
|
|
|
# Check domain/path availability asap
|
2015-08-21 10:46:31 +02:00
|
|
|
check=`sudo yunohost app checkurl $domain$path -a $app`
|
|
|
|
if [ ! $? -eq 0 ]
|
|
|
|
then
|
|
|
|
echo $check
|
2015-08-19 17:41:15 +02:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2015-08-20 12:20:05 +02:00
|
|
|
admin=$3
|
2015-08-20 16:29:29 +02:00
|
|
|
admin_password=$4
|
2019-01-04 18:28:10 +01:00
|
|
|
is_public=$YNH_APP_ARG_IS_PUBLIC
|
|
|
|
|
2015-08-20 16:46:26 +02:00
|
|
|
directory=/var/www/$app
|
2015-08-20 16:29:29 +02:00
|
|
|
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'`
|
2015-08-20 16:46:26 +02:00
|
|
|
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'`
|
2015-08-21 13:39:11 +02:00
|
|
|
timezone=`cat /etc/timezone | tr -d '\n'`
|
2015-08-19 17:41:15 +02:00
|
|
|
|
2015-08-20 12:20:05 +02:00
|
|
|
# Save app settings
|
|
|
|
sudo yunohost app setting $app admin -v "$admin"
|
2015-08-20 16:29:29 +02:00
|
|
|
sudo yunohost app setting $app admin_password -v "$admin_password"
|
2015-08-20 12:20:05 +02:00
|
|
|
sudo yunohost app setting $app is_public -v "$is_public"
|
2015-08-19 17:41:15 +02:00
|
|
|
|
2015-08-20 12:20:05 +02:00
|
|
|
# Make sure we got the tools we need for this install
|
2015-08-21 09:47:59 +02:00
|
|
|
sudo apt-get install -y curl wget sed
|
2015-08-19 17:41:15 +02:00
|
|
|
|
|
|
|
# Initialize database and store mysql password for upgrade
|
2015-08-20 16:29:29 +02:00
|
|
|
db_password=`sudo yunohost app initdb $app | tr -d '\n'`
|
2015-08-21 15:33:45 +02:00
|
|
|
sudo yunohost app setting $app db_password -v $db_password
|
2015-08-19 17:41:15 +02:00
|
|
|
|
|
|
|
# Get sources
|
2015-08-21 11:02:01 +02:00
|
|
|
sudo wget -nv http://download.dotclear.org/latest.tar.gz -O $app.tgz
|
2015-08-20 12:20:05 +02:00
|
|
|
sudo tar xf $app.tgz
|
2015-08-21 09:39:52 +02:00
|
|
|
sudo mv dotclear $directory
|
2015-08-20 12:20:05 +02:00
|
|
|
sudo rm -f $app.tgz
|
2015-08-21 09:47:59 +02:00
|
|
|
sudo cp $php_config.in $php_config
|
2015-08-21 10:51:32 +02:00
|
|
|
sudo chown www-data:www-data -R $directory
|
2015-08-19 17:41:15 +02:00
|
|
|
|
|
|
|
# Config as if we called in admin/install/wizard.php
|
2019-01-04 18:10:25 +01:00
|
|
|
sudo sed -i -e "s;'DC_DBDRIVER', '';'DC_DBDRIVER', 'mysqli';" -e "s;'DC_DBHOST', '';'DC_DBHOST', 'localhost';" -e "s;'DC_DBUSER', '';'DC_DBUSER', '$app';" -e "s;'DC_DBPASSWORD', '';'DC_DBPASSWORD', '$db_password';" -e "s;'DC_DBNAME', '';'DC_DBNAME', '$app';" -e "s;'DC_MASTER_KEY', '';'DC_MASTER_KEY', '$master_key';" -e "s;'DC_ADMIN_URL', '';'DC_ADMIN_URL', 'https://$domain$path/admin/index.php';" -e "s;'DC_ADMIN_MAILFROM', '';'DC_ADMIN_MAILFROM', '$email';" $php_config
|
2015-08-19 17:41:15 +02:00
|
|
|
# Modify Nginx configuration file and copy it to Nginx conf directory
|
2015-08-20 12:20:05 +02:00
|
|
|
sed -i "s@YNH_WWW_PATH@$path@g" ../conf/nginx.conf
|
2015-08-21 10:01:34 +02:00
|
|
|
sed -i "s@YNH_WWW_ALIAS@$directory/@g" ../conf/nginx.conf
|
2015-08-20 12:20:05 +02:00
|
|
|
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf
|
2015-09-11 23:07:07 +02:00
|
|
|
sudo /etc/init.d/nginx reload
|
2015-08-20 12:20:05 +02:00
|
|
|
|
2015-09-14 22:04:15 +02:00
|
|
|
# Removing protection like a public app to finish installation
|
|
|
|
sudo yunohost app setting $app unprotected_uris -v "/"
|
|
|
|
sudo yunohost app ssowatconf
|
|
|
|
|
2015-09-11 23:07:07 +02:00
|
|
|
# Setting first user details and filling database calling admin/install/index.php
|
|
|
|
success=`curl -L --cacert /etc/yunohost/certs/$domain/ca.pem -F "u_email=$email" -F "u_firstname=$firstname" -F "u_name=$lastname" -F "u_login=$admin" -F "u_pwd=$admin_password" -F "u_pwd2=$admin_password" -F "u_date=$timezone" https://$domain$path/admin/install/index.php`
|
|
|
|
# success=`curl -L --cacert /etc/yunohost/certs/$domain/ca.pem -H 'Host: $domain' -X POST --data '?u_email=$EMAIL&u_firstname=$FIRSTNAME&u_name=$NAME&u_login=$LOGIN&u_pwd=$admin_password&u_pwd2=$admin_password&u_date=$timezone' https://$domain$path/admin/install/index.php`
|
|
|
|
|
|
|
|
# Now that we curl'ed the setup we can lock the UI if it's private
|
2015-09-14 22:04:15 +02:00
|
|
|
# If app is public, leave as it is
|
2019-01-04 18:28:10 +01:00
|
|
|
if [ $is_public -eq 0 ];
|
2015-08-20 12:20:05 +02:00
|
|
|
then
|
|
|
|
# unprotected_uris allows SSO credentials to be passed anyway.
|
2015-09-14 22:04:15 +02:00
|
|
|
sudo yunohost app setting $app protected_uris -v "/"
|
|
|
|
sudo yunohost app ssowatconf
|
2015-08-20 12:20:05 +02:00
|
|
|
fi
|
2015-09-11 17:33:07 +02:00
|
|
|
|
2015-08-19 17:41:15 +02:00
|
|
|
# Success or not success
|
2015-08-20 16:46:26 +02:00
|
|
|
if [ `echo $success | grep -c success` -gt 0 ]
|
2015-08-19 17:41:15 +02:00
|
|
|
then
|
2015-08-20 16:29:29 +02:00
|
|
|
echo Installation OK, $app should be available here https://$domain$path/
|
2015-08-19 17:41:15 +02:00
|
|
|
else
|
2015-08-20 16:29:29 +02:00
|
|
|
echo Using curl to finish setup failed, open https://$domain$path/admin/install/index.php and do it yourself
|
2015-08-19 17:41:15 +02:00
|
|
|
fi
|
2015-09-14 23:18:02 +02:00
|
|
|
exit 0
|
2015-08-19 17:41:15 +02:00
|
|
|
|