diff --git a/scripts/backup b/scripts/backup index a92aad8..6e3da91 100755 --- a/scripts/backup +++ b/scripts/backup @@ -1,14 +1,14 @@ #!/bin/bash # Exit on command errors and treat unset variables as an error -set -eu +#set -eu -TRAP_ON () { # Activate signal capture - trap EXIT_PROPERLY ERR # Capturing ex it signals on error -} +#TRAP_ON () { # Activate signal capture +# trap EXIT_PROPERLY ERR # Capturing ex it signals on error +#} # Active trap pour arrêter le script si une erreur est détectée. -TRAP_ON +#TRAP_ON # See comments in install script app=$YNH_APP_INSTANCE_NAME diff --git a/scripts/install b/scripts/install index 9e11d3c..d2e06e1 100755 --- a/scripts/install +++ b/scripts/install @@ -1,5 +1,5 @@ #!/bin/bash -set -eu +#set -eu # Charge les fonctions génériques habituellement utilisées dans le script source fonctions @@ -25,9 +25,9 @@ basicauthpass=$YNH_APP_ARG_BASICAUTHPASS CHECK_VAR "$app" "app name not set" # Check the path value and correct it (adds / at begining and removes it at the end) -CHECK_PATH +CHECK_PATH; -CHECK_CALIBREPATH +CHECK_CALIBREPATH; # Check domain and path availibility CHECK_DOMAINPATH @@ -56,18 +56,25 @@ sudo apt-get update -y sudo apt-get install php5-gd php5-sqlite php5-json php5-intl -y # Creation of folder -#sudo rm -rf $final_path sudo mkdir -p $final_path +# We download the sources and check the md5sum +cops_file=`sudo cat ../sources/source_file`; +sudo wget -nv -i ../sources/source_url -P ../sources/ +sudo md5sum -c ../sources/source_md5 --status || (echo "Corrupt source" >&2 && false) +sudo unzip ../sources/${cops_file} -d $final_path + # Site adjustments -sudo cp ../conf/config_local.php ../sources/ -sed -i "s@CALIBRETOCHANGE@$calibrepath@g" ../sources/config_local.php +sed -i "s@CALIBRETOCHANGE@$calibrepath@g" ../conf/config_local.php timezone=`sudo cat /etc/timezone`; -sed -i "s@TIMEZONETOCHANGE@$timezone@g" ../sources/config_local.php +sed -i "s@TIMEZONETOCHANGE@$timezone@g" ../conf/config_local.php -sudo cp ../conf/robots.txt ../sources/ +sudo cp ../conf/config_local.php $final_path +sudo cp ../conf/robots.txt $final_path -# To be done : make it an if loop +# Set permissions +sudo chmod 775 -R $final_path +sudo chown -hR $runninguser:$runninguser $final_path # Add basic auth if requested if [ "$basicauthcreate" = "Yes" ]; @@ -82,6 +89,9 @@ then sed 's#$#'"`echo -n $SALT | xxd -ps`"'#' | xxd -r -ps | base64);printf "$basicauthuser:{SSHA}$SHA1\n" >> ../sources/htpasswd) + sudo cp ../sources/htpasswd $final_path + sudo chmod 440 $final_path/htpasswd + sudo chown www-data:www-data $final_path/htpasswd # Modif nginx sed -i "s|^.*\bauth_basic\b.*$| auth_basic \"Private Library\";|" ../conf/nginx.conf; @@ -90,33 +100,16 @@ else echo "No basic auth"; fi -# Base site -sudo cp -a ../sources/* $final_path/ - -# Set permissions -sudo chmod 775 -R $final_path -sudo chown -hR $runninguser:$runninguser $final_path - -if [ "$basicauthcreate" = "Yes" ]; -then - sudo chmod 440 $final_path/htpasswd - sudo chown www-data:www-data $final_path/htpasswd -else - echo "Nothing to do" -fi - - -# Modify Nginx configuration file and copy it to Nginx conf directory +# Modify Nginx configuration file and copy it to Nginx conf.d directory sed -i "s@PATHTOCHANGE@$path@g" ../conf/nginx.conf sed -i "s@ALIASTOCHANGE@$final_path/@g" ../conf/nginx.conf sed -i "s@NAMETOCHANGE@$app@g" ../conf/nginx.conf sudo cp ../conf/nginx.conf $finalnginxconf - +# Modify php-fpm configuration file and copy it to php-fpm pool.d directory sed -i "s@NAMETOCHANGE@$app@g" ../conf/php-fpm.conf sed -i "s@FOLDERTOCHANGE@$final_path@g" ../conf/php-fpm.conf sed -i "s@USERTOCHANGE@$runninguser@g" ../conf/php-fpm.conf - sudo cp ../conf/php-fpm.conf $finalphpconf sudo chown root: $finalphpconf sudo chmod 644 $finalphpconf @@ -128,7 +121,6 @@ then ynh_app_setting_set $app skipped_uris "/" fi - # Reload Nginx and regenerate SSOwat conf sudo service php5-fpm reload sudo service nginx reload diff --git a/scripts/remove b/scripts/remove index e2a7896..d2cefb0 100755 --- a/scripts/remove +++ b/scripts/remove @@ -1,11 +1,11 @@ #!/bin/bash -set -eu +#set -eu # Charge les fonctions génériques habituellement utilisées dans le script -source fonctions +#source fonctions # Active trap pour arrêter le script si une erreur est détectée. -TRAP_ON +#TRAP_ON # Source app helpers source /usr/share/yunohost/helpers diff --git a/scripts/restore b/scripts/restore index bdc323d..b23d27b 100755 --- a/scripts/restore +++ b/scripts/restore @@ -4,14 +4,14 @@ # will be located in the current directory, regarding the last argument. # Exit on command errors and treat unset variables as an error -set -eu +#set -eu -TRAP_ON () { # Activate signal capture - trap EXIT_PROPERLY ERR # Capturing ex it signals on error -} +#TRAP_ON () { # Activate signal capture +# trap EXIT_PROPERLY ERR # Capturing ex it signals on error +#} # Active trap pour arrêter le script si une erreur est détectée. -TRAP_ON +#TRAP_ON # See comments in install script app=$YNH_APP_INSTANCE_NAME @@ -49,16 +49,6 @@ else echo "Nothing to do" fi -### MySQL (remove if not used) ### -# If a MySQL database is used: -# # Create and restore the database -# dbname=$app -# dbuser=$app -# dbpass=$(ynh_app_setting_get "$app" mysqlpwd) -# ynh_mysql_create_db "$dbname" "$dbuser" "$dbpass" -# ynh_mysql_connect_as "$dbuser" "$dbpass" "$dbname" < ./dump.sql -### MySQL end ### - # Restore NGINX configuration sudo cp -a ./nginx.conf $finalnginxconf diff --git a/scripts/upgrade b/scripts/upgrade index 04d3b31..83ef41c 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -1,11 +1,11 @@ #!/bin/bash -set -eu +#set -eu # Charge les fonctions génériques habituellement utilisées dans le script source fonctions # Active trap pour arrêter le script si une erreur est détectée. -TRAP_ON +#TRAP_ON # Source app helpers source /usr/share/yunohost/helpers @@ -28,6 +28,32 @@ basicauthcreate=$(ynh_app_setting_get $app basicauthcreate) # We check that calibrepath is correct CHECK_CALIBREPATH +# We install dependencies +sudo apt-get update -y +sudo apt-get install php5-gd php5-sqlite php5-json php5-intl -y + +# Removal of old folder and restart from fresh +sudo rm -rf $final_path +sudo mkdir -p $final_path + +# We download the sources and check the md5sum +cops_file=`sudo cat ../sources/source_file`; +sudo wget -nv -i ../sources/source_url -P ../sources/ +sudo md5sum -c ../sources/source_md5 --status || (echo "Corrupt source" >&2 && false) +sudo unzip ../sources/${cops_file} -d $final_path + +# Site adjustments +sed -i "s@CALIBRETOCHANGE@$calibrepath@g" ../conf/config_local.php +timezone=`sudo cat /etc/timezone`; +sed -i "s@TIMEZONETOCHANGE@$timezone@g" ../conf/config_local.php + +sudo cp ../conf/config_local.php $final_path +sudo cp ../conf/robots.txt $final_path + +# Set permissions +sudo chmod 775 -R $final_path +sudo chown -hR $runninguser:$runninguser $final_path + # Add basic auth if requested if [ "$basicauthcreate" = "Yes" ]; then @@ -41,62 +67,31 @@ then sed 's#$#'"`echo -n $SALT | xxd -ps`"'#' | xxd -r -ps | base64);printf "$basicauthuser:{SSHA}$SHA1\n" >> ../sources/htpasswd) + sudo cp ../sources/htpasswd $final_path + sudo chmod 440 $final_path/htpasswd + sudo chown www-data:www-data $final_path/htpasswd # Modif nginx - sed -i "s|^.*\bauth_basic\b.*$| auth_basic \"Private Library\";|" ../conf/nginx.conf; - sed -i "s|^.*\bauth_basic_user_file\b.*$| auth_basic_user_file $final_path/htpasswd;|" ../conf/nginx.conf; + sed -i "s|^.*\bauth_basic\b.*$| auth_basic \"Private Library\";|" ../conf/nginx.conf; + sed -i "s|^.*\bauth_basic_user_file\b.*$| auth_basic_user_file $final_path/htpasswd;|" ../conf/nginx.conf; else echo "No basic auth"; fi - -# We install dependencies -sudo apt-get update -y -sudo apt-get install php5-gd php5-sqlite php5-json php5-intl -y - -# Modify Nginx configuration file and copy it to Nginx conf directory +# Modify Nginx configuration file and copy it to Nginx conf.d directory sed -i "s@PATHTOCHANGE@$path@g" ../conf/nginx.conf sed -i "s@ALIASTOCHANGE@$final_path/@g" ../conf/nginx.conf sed -i "s@NAMETOCHANGE@$app@g" ../conf/nginx.conf sudo cp ../conf/nginx.conf $finalnginxconf - +# Modify php-fpm configuration file and copy it to php-fpm pool.d directory sed -i "s@NAMETOCHANGE@$app@g" ../conf/php-fpm.conf sed -i "s@FOLDERTOCHANGE@$final_path@g" ../conf/php-fpm.conf sed -i "s@USERTOCHANGE@$runninguser@g" ../conf/php-fpm.conf - sudo cp ../conf/php-fpm.conf $finalphpconf sudo chown root: $finalphpconf sudo chmod 644 $finalphpconf -# Removal of old folder and restart from fresh -sudo rm -rf $final_path -sudo mkdir -p $final_path - -# Site adjustments -sudo cp ../conf/config_local.php ../sources/ -sed -i "s@CALIBRETOCHANGE@$calibrepath@g" ../sources/config_local.php -timezone=`sudo cat /etc/timezone`; -sed -i "s@TIMEZONETOCHANGE@$timezone@g" ../sources/config_local.php - -sudo cp ../conf/robots.txt ../sources/ - -# Base site -sudo cp -a ../sources/* $final_path/ - -# We adjust permissions -sudo chmod 775 -R $final_path -sudo chown -hR $runninguser:$runninguser $final_path - -if [ "$basicauthcreate" = "Yes" ]; -then - sudo chmod 440 $final_path/htpasswd - sudo chown www-data:www-data $final_path/htpasswd -else - echo "Nothing to do" -fi - - # Make app public if necessary is_public=$(ynh_app_setting_get $app is_public) if [ "$is_public" = "Yes" ]; diff --git a/conf/robots.txt b/sources/robots.txt similarity index 100% rename from conf/robots.txt rename to sources/robots.txt diff --git a/sources/source_file b/sources/source_file new file mode 100644 index 0000000..a8b88ec --- /dev/null +++ b/sources/source_file @@ -0,0 +1 @@ +cops-1.0.1.zip diff --git a/sources/source_md5 b/sources/source_md5 new file mode 100644 index 0000000..3f3b2ba --- /dev/null +++ b/sources/source_md5 @@ -0,0 +1 @@ +a688dfd66d31674637106f8430ca1103 cops-1.0.1.zip diff --git a/sources/source_url b/sources/source_url new file mode 100644 index 0000000..6519215 --- /dev/null +++ b/sources/source_url @@ -0,0 +1 @@ +https://github.com/seblucas/cops/releases/download/1.0.1/cops-1.0.1.zip