1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/dotclear2_ynh.git synced 2024-09-03 18:26:29 +02:00

Beta version of install script

This commit is contained in:
Rémy Garrigue 2015-08-20 10:20:05 +00:00
parent 9e444cbd1f
commit 3f1ef1c698

View file

@ -1,74 +1,84 @@
# Arguments #!/bin/bash
# DotClear 2 installation script for YunoHost
# First arguments
app=dotclear2
domain=$1 domain=$1
path=$2 path=$2
# Check domain/path availability # Check domain/path availability asap
sudo yunohost app checkurl $domain$path -a dotclear2 sudo yunohost app checkurl $domain$path -a $app
if [[ ! $? -eq 0 ]]; then if [[ ! $? -eq 0 ]]; then
exit 1 exit 1
fi fi
# Install dependencies # Other arguments
sudo apt install -y curl wget sed admin=$3
password=$4
# Other variables is_public=$5
DIR=/var/www/dotclear2 directory=/var/www/$app/
CONF="$DIR/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')"
DC_DBDRIVER=mysqli 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')
DC_DBHOST=localhost firstname=`sudo yunohost user info $admin | grep firstname | cut -d' ' -f2 | tr -d '\n'`
DC_DBUSER=dotclear lastname=`sudo yunohost user info $admin | grep lastname | cut -d' ' -f2 | tr -d '\n'`
DC_DBPASSWORD="$(dd if=/dev/urandom bs=1 count=200 2> /dev/null | tr -c -d '[A-Za-z0-9]' | sed -n 's/\(.\{24\}\).*/\1/p')" email=`sudo yunohost user info $admin | grep mail | cut -d' ' -f2 | tr -d '\n'`
DC_DBNAME=dotclear
DC_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')
DC_ADMIN_URL="https://$domain$path/admin/index.php"
EMAIL=root@localhost
FIRSTNAME=Rémy
NAME=Garrigue
LOGIN=remy
PWD=dotclear
TZ=Europe/Paris TZ=Europe/Paris
# Save app settings
sudo yunohost app setting $app admin -v "$admin"
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 # Initialize database and store mysql password for upgrade
sudo yunohost app initdb $DC_DBUSER -p $DC_DBPASSWORD sudo yunohost app initdb $app -p $db_password
sudo yunohost app setting dotclear2 mysqlpwd -v $DC_DBPASSWORD sudo yunohost app setting $app mysqlpwd -v $db_password
# Get sources # Get sources
sudo mkdir -p $DIR sudo mkdir -p $directory
cd $DIR cd $directory
sudo wget dotclear.tgz http://download.dotclear.org/latest.tar.gz -O dotclear.tgz sudo wget dotclear.tgz http://download.dotclear.org/latest.tar.gz -O $app.tgz
sudo tar xf dotclear.tgz sudo tar xf $app.tgz
sudo rm -f dotclear.tgz mv dotclear $app
sudo chown www-data:www-data -R dotclear sudo rm -f $app.tgz
sudo chown www-data:www-data -R $app
# Config as if we called in admin/install/wizard.php # Config as if we called in admin/install/wizard.php
sudo mv $CONF.in $CONF sudo mv $php_config.in $php_config
sudo sed -i -e "s;'DC_DBDRIVER','';'DC_DBDRIVER','$DC_DBDRIVER';" $CONF sudo sed -i -e "s;'DC_DBDRIVER','';'DC_DBDRIVER','mysqli';" \
sudo sed -i -e "s;'DC_DBHOST','';'DC_DBHOST','$DC_DBHOST';" $CONF -e "s;'DC_DBHOST','';'DC_DBHOST','localhost';" \
sudo sed -i -e "s;'DC_DBUSER','';'DC_DBUSER','$DC_DBUSER';" $CONF -e "s;'DC_DBUSER','';'DC_DBUSER','$app';" \
sudo sed -i -e "s;'DC_DBPASSWORD','';'DC_DBPASSWORD','$DC_DBPASSWORD';" $CONF -e "s;'DC_DBPASSWORD','';'DC_DBPASSWORD','$db_password';" \
sudo sed -i -e "s;'DC_DBNAME','';'DC_DBNAME','$DC_DBNAME';" $CONF -e "s;'DC_DBNAME','';'DC_DBNAME','$app';" \
# sudo sed -i -e "s;'DC_DBPREFIX','';'DC_DBPREFIX','dc_';" $CONF -e "s;'DC_MASTER_KEY','';'DC_MASTER_KEY','$master_key';" \
sudo sed -i -e "s;'DC_MASTER_KEY','';'DC_MASTER_KEY','$DC_MASTER_KEY';" $CONF -e "s;'DC_ADMIN_URL','';'DC_ADMIN_URL','https://$domain$path/admin/index.php';" \
sudo sed -i -e "s;'DC_ADMIN_URL','';'DC_ADMIN_URL','$DC_ADMIN_URL';" $CONF -e "s;'DC_ADMIN_MAILFROM','';'DC_ADMIN_MAILFROM','$email';" $php_config
sudo sed -i -e "s;'DC_ADMIN_MAILFROM','';'DC_ADMIN_MAILFROM','$EMAIL';" $CONF
# Modify Nginx configuration file and copy it to Nginx conf directory # Modify Nginx configuration file and copy it to Nginx conf directory
sed -i "s;PATHTOCHANGE;$path;g" ../conf/nginx.conf sed -i "s@YNH_WWW_PATH@$path@g" ../conf/nginx.conf
sed -i "s;ALIASTOCHANGE;$DIR/;g" ../conf/nginx.conf sed -i "s@YNH_WWW_ALIAS@$final_path/@g" ../conf/nginx.conf
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/dotclear2.conf sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf
# If app is public, add url to SSOWat conf as skipped_uris
if [ "$is_public" = "Yes" ];
then
# unprotected_uris allows SSO credentials to be passed anyway.
sudo yunohost app setting $app unprotected_uris -v "/"
fi
# Reload Nginx and regenerate SSOwat conf # Reload Nginx and regenerate SSOwat conf
sudo service nginx reload 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
CURL=`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=$PWD" -F "u_pwd2=$PWD" -F "u_date=$TZ" $domain$path/admin/install/index.php`
# Success or not success # Success or not success
if [ `echo $CURL | grep -c success` -ge 0 ] if [ `echo $success | grep -c success` -ge 0 ]
then then
echo OK echo Installation OK, $app should be available here $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 $domain$path/admin/install/index.php and do it yourself