diff --git a/manifest.json b/manifest.json new file mode 100644 index 0000000..e7f0d4a --- /dev/null +++ b/manifest.json @@ -0,0 +1,34 @@ +{ + "name": "DotClear 2", + "id": "dotclear2", + "description": { + "en": "Blog publishing application", + "fr": "Moteur de blog" + }, + "license": "GPL-3", + "maintainer": { + "name": "rgarrigue", + "email": "remy.garrigue@gmail.com", + "url": "http://garrigue.re" + }, + "multi_instance": "false", + "arguments": { + "install" : [ + { + "name": "domain", + "ask": { + "en": "Choose a domain for DotClear 2" + }, + "example": "domain.org" + }, + { + "name": "path", + "ask": { + "en": "Choose a path for DotClear 2" + }, + "example": "/dc", + "default": "/dc" + } + ] + } +} diff --git a/scripts/backup b/scripts/backup new file mode 100644 index 0000000..e69de29 diff --git a/scripts/install b/scripts/install new file mode 100755 index 0000000..7f3fe82 --- /dev/null +++ b/scripts/install @@ -0,0 +1,77 @@ +# Arguments +domain=$1 +path=$2 + +# Check domain/path availability +sudo yunohost app checkurl $domain$path -a dotclear2 +if [[ ! $? -eq 0 ]]; then + exit 1 +fi + +# Install dependencies +sudo apt install -y curl wget sed + +# Other variables +DIR=/var/www/dotclear2 +CONF="$DIR/inc/config.php" + +DC_DBDRIVER=mysqli +DC_DBHOST=localhost +DC_DBUSER=dotclear +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')" +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 + +# Initialize database and store mysql password for upgrade +sudo yunohost app initdb $DC_DBUSER -p $DC_DBPASSWORD +sudo yunohost app setting dotclear2 mysqlpwd -v $DC_DBPASSWORD + +# Get sources +sudo mkdir -p $DIR +cd $DIR +sudo wget dotclear.tgz http://download.dotclear.org/latest.tar.gz -O dotclear.tgz +sudo tar xf dotclear.tgz +sudo rm -f dotclear.tgz +sudo chown www-data:www-data -R dotclear + +# Config as if we called in admin/install/wizard.php +sudo mv $CONF.in $CONF +sudo sed -i -e "s;'DC_DBDRIVER','';'DC_DBDRIVER','$DC_DBDRIVER';" $CONF +sudo sed -i -e "s;'DC_DBHOST','';'DC_DBHOST','$DC_DBHOST';" $CONF +sudo sed -i -e "s;'DC_DBUSER','';'DC_DBUSER','$DC_DBUSER';" $CONF +sudo sed -i -e "s;'DC_DBPASSWORD','';'DC_DBPASSWORD','$DC_DBPASSWORD';" $CONF +sudo sed -i -e "s;'DC_DBNAME','';'DC_DBNAME','$DC_DBNAME';" $CONF +# sudo sed -i -e "s;'DC_DBPREFIX','';'DC_DBPREFIX','dc_';" $CONF +sudo sed -i -e "s;'DC_MASTER_KEY','';'DC_MASTER_KEY','$DC_MASTER_KEY';" $CONF +sudo sed -i -e "s;'DC_ADMIN_URL','';'DC_ADMIN_URL','$DC_ADMIN_URL';" $CONF +sudo sed -i -e "s;'DC_ADMIN_MAILFROM','';'DC_ADMIN_MAILFROM','$EMAIL';" $CONF + +# Modify Nginx configuration file and copy it to Nginx conf directory +sed -i "s;PATHTOCHANGE;$path;g" ../conf/nginx.conf +sed -i "s;ALIASTOCHANGE;$DIR/;g" ../conf/nginx.conf +sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/dotclear2.conf + +# Reload Nginx and regenerate SSOwat conf +sudo service nginx reload +sudo yunohost app ssowatconf + +# 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 or not success +if [ `echo $CURL | grep -c success` -ge 0 ] +then + echo OK + exit 0 +else + echo Using curl to finish setup failed, open $domain$path/admin/install/index.php and do it yourself + exit 1 +fi + diff --git a/scripts/remove b/scripts/remove new file mode 100644 index 0000000..e69de29 diff --git a/scripts/restore b/scripts/restore new file mode 100644 index 0000000..e69de29 diff --git a/scripts/upgrade b/scripts/upgrade new file mode 100644 index 0000000..e69de29