mirror of
https://github.com/YunoHost-Apps/abantecart_ynh.git
synced 2024-09-03 18:06:16 +02:00
Merge pull request #1 from YunoHost-Apps/master
Update to latest code base
This commit is contained in:
commit
27a8b953d1
12 changed files with 505 additions and 36 deletions
|
@ -3,7 +3,11 @@
|
|||
; Manifest
|
||||
domain="domain.tld" (DOMAIN)
|
||||
path="/path" (PATH)
|
||||
is_public=0 (PUBLIC|public=0|private=1)
|
||||
is_public="Yes" (PUBLIC|public=Yes|private=No)
|
||||
user="john" (USER)
|
||||
passwd="$PASSWORD" (PASSWORD)
|
||||
email="abc@example.com"
|
||||
|
||||
; Checks
|
||||
pkg_linter=1
|
||||
setup_sub_dir=1
|
||||
|
@ -11,10 +15,10 @@
|
|||
setup_nourl=0
|
||||
setup_private=1
|
||||
setup_public=1
|
||||
upgrade=1
|
||||
backup_restore=1
|
||||
upgrade=0
|
||||
backup_restore=0
|
||||
multi_instance=1
|
||||
wrong_user=0
|
||||
wrong_user=1
|
||||
wrong_path=1
|
||||
incorrect_path=1
|
||||
corrupt_source=0
|
||||
|
@ -25,7 +29,7 @@
|
|||
Level 1=auto
|
||||
Level 2=auto
|
||||
Level 3=auto
|
||||
Level 4=0
|
||||
Level 4=na
|
||||
Level 5=auto
|
||||
Level 6=auto
|
||||
Level 7=auto
|
||||
|
|
14
conf/abantecart-deps.control
Normal file
14
conf/abantecart-deps.control
Normal file
|
@ -0,0 +1,14 @@
|
|||
Section: misc
|
||||
Priority: optional
|
||||
Homepage: http://www.abantecart.com/
|
||||
Standards-Version: 1.2.9
|
||||
|
||||
Package: abantecart-deps
|
||||
Version: 1.2-1
|
||||
Depends: php5-mysql
|
||||
Architecture: all
|
||||
Description: meta package for abantecart dependencies
|
||||
The Most Powerful eCommerce Platform to Sell anything.
|
||||
.
|
||||
.
|
||||
This meta-package is only responsible of installing its dependencies.
|
|
@ -7,7 +7,7 @@ location YNH_WWW_PATH {
|
|||
try_files $uri $uri/ index.php;
|
||||
location ~ [^/]\.php(/|$) {
|
||||
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
|
||||
fastcgi_pass unix:/var/run/php5-fpm.sock;
|
||||
fastcgi_pass unix:/var/run/php5-fpm-NAMETOCHANGE.sock;
|
||||
fastcgi_index index.php;
|
||||
include fastcgi_params;
|
||||
fastcgi_param REMOTE_USER $remote_user;
|
||||
|
|
243
conf/php-fpm.conf
Normal file
243
conf/php-fpm.conf
Normal file
|
@ -0,0 +1,243 @@
|
|||
; Start a new pool named 'www'.
|
||||
; the variable $pool can we used in any directive and will be replaced by the
|
||||
; pool name ('www' here)
|
||||
[NAMETOCHANGE]
|
||||
|
||||
; Per pool prefix
|
||||
; It only applies on the following directives:
|
||||
; - 'slowlog'
|
||||
; - 'listen' (unixsocket)
|
||||
; - 'chroot'
|
||||
; - 'chdir'
|
||||
; - 'php_values'
|
||||
; - 'php_admin_values'
|
||||
; When not set, the global prefix (or /usr) applies instead.
|
||||
; Note: This directive can also be relative to the global prefix.
|
||||
; Default Value: none
|
||||
;prefix = /path/to/pools/$pool
|
||||
|
||||
; The address on which to accept FastCGI requests.
|
||||
; Valid syntaxes are:
|
||||
; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific address on
|
||||
; a specific port;
|
||||
; 'port' - to listen on a TCP socket to all addresses on a
|
||||
; specific port;
|
||||
; '/path/to/unix/socket' - to listen on a unix socket.
|
||||
; Note: This value is mandatory.
|
||||
listen = /var/run/php5-fpm-NAMETOCHANGE.sock
|
||||
|
||||
; Set listen(2) backlog. A value of '-1' means unlimited.
|
||||
; Default Value: 128 (-1 on FreeBSD and OpenBSD)
|
||||
;listen.backlog = -1
|
||||
|
||||
; List of ipv4 addresses of FastCGI clients which are allowed to connect.
|
||||
; Equivalent to the FCGI_WEB_SERVER_ADDRS environment variable in the original
|
||||
; PHP FCGI (5.2.2+). Makes sense only with a tcp listening socket. Each address
|
||||
; must be separated by a comma. If this value is left blank, connections will be
|
||||
; accepted from any ip address.
|
||||
; Default Value: any
|
||||
;listen.allowed_clients = 127.0.0.1
|
||||
|
||||
; Set permissions for unix socket, if one is used. In Linux, read/write
|
||||
; permissions must be set in order to allow connections from a web server. Many
|
||||
; BSD-derived systems allow connections regardless of permissions.
|
||||
; Default Values: user and group are set as the running user
|
||||
; mode is set to 0666
|
||||
listen.owner = www-data
|
||||
listen.group = www-data
|
||||
listen.mode = 0600
|
||||
|
||||
; Unix user/group of processes
|
||||
; Note: The user is mandatory. If the group is not set, the default user's group
|
||||
; will be used.
|
||||
user = www-data
|
||||
group = www-data
|
||||
|
||||
; Choose how the process manager will control the number of child processes.
|
||||
; Possible Values:
|
||||
; static - a fixed number (pm.max_children) of child processes;
|
||||
; dynamic - the number of child processes are set dynamically based on the
|
||||
; following directives:
|
||||
; pm.max_children - the maximum number of children that can
|
||||
; be alive at the same time.
|
||||
; pm.start_servers - the number of children created on startup.
|
||||
; pm.min_spare_servers - the minimum number of children in 'idle'
|
||||
; state (waiting to process). If the number
|
||||
; of 'idle' processes is less than this
|
||||
; number then some children will be created.
|
||||
; pm.max_spare_servers - the maximum number of children in 'idle'
|
||||
; state (waiting to process). If the number
|
||||
; of 'idle' processes is greater than this
|
||||
; number then some children will be killed.
|
||||
; Note: This value is mandatory.
|
||||
pm = dynamic
|
||||
|
||||
; The number of child processes to be created when pm is set to 'static' and the
|
||||
; maximum number of child processes to be created when pm is set to 'dynamic'.
|
||||
; This value sets the limit on the number of simultaneous requests that will be
|
||||
; served. Equivalent to the ApacheMaxClients directive with mpm_prefork.
|
||||
; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP
|
||||
; CGI.
|
||||
; Note: Used when pm is set to either 'static' or 'dynamic'
|
||||
; Note: This value is mandatory.
|
||||
pm.max_children = 6
|
||||
|
||||
; The number of child processes created on startup.
|
||||
; Note: Used only when pm is set to 'dynamic'
|
||||
; Default Value: min_spare_servers + (max_spare_servers - min_spare_servers) / 2
|
||||
pm.start_servers = 3
|
||||
|
||||
; The desired minimum number of idle server processes.
|
||||
; Note: Used only when pm is set to 'dynamic'
|
||||
; Note: Mandatory when pm is set to 'dynamic'
|
||||
pm.min_spare_servers = 3
|
||||
|
||||
; The desired maximum number of idle server processes.
|
||||
; Note: Used only when pm is set to 'dynamic'
|
||||
; Note: Mandatory when pm is set to 'dynamic'
|
||||
pm.max_spare_servers = 5
|
||||
|
||||
; The number of requests each child process should execute before respawning.
|
||||
; This can be useful to work around memory leaks in 3rd party libraries. For
|
||||
; endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS.
|
||||
; Default Value: 0
|
||||
pm.max_requests = 500
|
||||
|
||||
; The URI to view the FPM status page. If this value is not set, no URI will be
|
||||
; recognized as a status page. By default, the status page shows the following
|
||||
; information:
|
||||
; accepted conn - the number of request accepted by the pool;
|
||||
; pool - the name of the pool;
|
||||
; process manager - static or dynamic;
|
||||
; idle processes - the number of idle processes;
|
||||
; active processes - the number of active processes;
|
||||
; total processes - the number of idle + active processes.
|
||||
; max children reached - number of times, the process limit has been reached,
|
||||
; when pm tries to start more children (works only for
|
||||
; pm 'dynamic')
|
||||
; The values of 'idle processes', 'active processes' and 'total processes' are
|
||||
; updated each second. The value of 'accepted conn' is updated in real time.
|
||||
; Example output:
|
||||
; accepted conn: 12073
|
||||
; pool: www
|
||||
; process manager: static
|
||||
; idle processes: 35
|
||||
; active processes: 65
|
||||
; total processes: 100
|
||||
; max children reached: 1
|
||||
; By default the status page output is formatted as text/plain. Passing either
|
||||
; 'html' or 'json' as a query string will return the corresponding output
|
||||
; syntax. Example:
|
||||
; http://www.foo.bar/status
|
||||
; http://www.foo.bar/status?json
|
||||
; http://www.foo.bar/status?html
|
||||
; Note: The value must start with a leading slash (/). The value can be
|
||||
; anything, but it may not be a good idea to use the .php extension or it
|
||||
; may conflict with a real PHP file.
|
||||
; Default Value: not set
|
||||
pm.status_path = /fpm-status
|
||||
|
||||
; The ping URI to call the monitoring page of FPM. If this value is not set, no
|
||||
; URI will be recognized as a ping page. This could be used to test from outside
|
||||
; that FPM is alive and responding, or to
|
||||
; - create a graph of FPM availability (rrd or such);
|
||||
; - remove a server from a group if it is not responding (load balancing);
|
||||
; - trigger alerts for the operating team (24/7).
|
||||
; Note: The value must start with a leading slash (/). The value can be
|
||||
; anything, but it may not be a good idea to use the .php extension or it
|
||||
; may conflict with a real PHP file.
|
||||
; Default Value: not set
|
||||
ping.path = /ping
|
||||
|
||||
; This directive may be used to customize the response of a ping request. The
|
||||
; response is formatted as text/plain with a 200 response code.
|
||||
; Default Value: pong
|
||||
;ping.response = pong
|
||||
|
||||
; The timeout for serving a single request after which the worker process will
|
||||
; be killed. This option should be used when the 'max_execution_time' ini option
|
||||
; does not stop script execution for some reason. A value of '0' means 'off'.
|
||||
; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
|
||||
; Default Value: 0
|
||||
request_terminate_timeout = 120s
|
||||
|
||||
; The timeout for serving a single request after which a PHP backtrace will be
|
||||
; dumped to the 'slowlog' file. A value of '0s' means 'off'.
|
||||
; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
|
||||
; Default Value: 0
|
||||
request_slowlog_timeout = 5s
|
||||
|
||||
; The log file for slow requests
|
||||
; Default Value: not set
|
||||
; Note: slowlog is mandatory if request_slowlog_timeout is set
|
||||
slowlog = /var/log/nginx/NAMETOCHANGE.slow.log
|
||||
|
||||
; Set open file descriptor rlimit.
|
||||
; Default Value: system defined value
|
||||
rlimit_files = 4096
|
||||
|
||||
; Set max core size rlimit.
|
||||
; Possible Values: 'unlimited' or an integer greater or equal to 0
|
||||
; Default Value: system defined value
|
||||
rlimit_core = 0
|
||||
|
||||
; Chroot to this directory at the start. This value must be defined as an
|
||||
; absolute path. When this value is not set, chroot is not used.
|
||||
; Note: you can prefix with '$prefix' to chroot to the pool prefix or one
|
||||
; of its subdirectories. If the pool prefix is not set, the global prefix
|
||||
; will be used instead.
|
||||
; Note: chrooting is a great security feature and should be used whenever
|
||||
; possible. However, all PHP paths will be relative to the chroot
|
||||
; (error_log, sessions.save_path, ...).
|
||||
; Default Value: not set
|
||||
;chroot =
|
||||
|
||||
; Chdir to this directory at the start.
|
||||
; Note: relative path can be used.
|
||||
; Default Value: current directory or / when chroot
|
||||
chdir = FOLDERTOCHANGE
|
||||
|
||||
; Redirect worker stdout and stderr into main error log. If not set, stdout and
|
||||
; stderr will be redirected to /dev/null according to FastCGI specs.
|
||||
; Note: on highloaded environement, this can cause some delay in the page
|
||||
; process time (several ms).
|
||||
; Default Value: no
|
||||
catch_workers_output = yes
|
||||
|
||||
; Pass environment variables like LD_LIBRARY_PATH. All $VARIABLEs are taken from
|
||||
; the current environment.
|
||||
; Default Value: clean env
|
||||
;env[HOSTNAME] = $HOSTNAME
|
||||
;env[PATH] = /usr/local/bin:/usr/bin:/bin
|
||||
;env[TMP] = /tmp
|
||||
;env[TMPDIR] = /tmp
|
||||
;env[TEMP] = /tmp
|
||||
|
||||
; Additional php.ini defines, specific to this pool of workers. These settings
|
||||
; overwrite the values previously defined in the php.ini. The directives are the
|
||||
; same as the PHP SAPI:
|
||||
; php_value/php_flag - you can set classic ini defines which can
|
||||
; be overwritten from PHP call 'ini_set'.
|
||||
; php_admin_value/php_admin_flag - these directives won't be overwritten by
|
||||
; PHP call 'ini_set'
|
||||
; For php_*flag, valid values are on, off, 1, 0, true, false, yes or no.
|
||||
|
||||
; Defining 'extension' will load the corresponding shared extension from
|
||||
; extension_dir. Defining 'disable_functions' or 'disable_classes' will not
|
||||
; overwrite previously defined php.ini values, but will append the new value
|
||||
; instead.
|
||||
|
||||
; Note: path INI options can be relative and will be expanded with the prefix
|
||||
; (pool, global or /usr)
|
||||
|
||||
; Default Value: nothing is defined by default except the values in php.ini and
|
||||
; specified at startup with the -d argument
|
||||
;php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f www@my.domain.com
|
||||
;php_flag[display_errors] = off
|
||||
;php_admin_value[error_log] = /var/log/fpm-php.www.log
|
||||
;php_admin_flag[log_errors] = on
|
||||
;php_admin_value[memory_limit] = 32M
|
||||
|
||||
;php_value[upload_max_filesize] = 10G
|
||||
;php_value[post_max_size] = 10G
|
||||
;php_value[mail.add_x_header] = Off
|
|
@ -15,7 +15,7 @@
|
|||
"name": "frju365",
|
||||
"email": "win10@tutanota.com"
|
||||
},
|
||||
"multi_instance": "true",
|
||||
"multi_instance": true,
|
||||
"services": [
|
||||
"nginx",
|
||||
"php5-fpm"
|
||||
|
|
|
@ -6,6 +6,36 @@ CHECK_VAR () { # Vérifie que la variable n'est pas vide.
|
|||
test -n "$1" || (echo "$2" >&2 && false)
|
||||
}
|
||||
|
||||
EXIT_PROPERLY () { # Provoque l'arrêt du script en cas d'erreur. Et nettoye les résidus.
|
||||
exit_code=$?
|
||||
if [ "$exit_code" -eq 0 ]; then
|
||||
exit 0 # Quitte sans erreur si le script se termine correctement.
|
||||
fi
|
||||
trap '' EXIT
|
||||
set +eu
|
||||
echo -e "\e[91m \e[1m" # Shell in light red bold
|
||||
echo -e "!!\n $app install's script has encountered an error. Installation was cancelled.\n!!" >&2
|
||||
|
||||
if type -t CLEAN_SETUP > /dev/null; then # Vérifie l'existance de la fonction avant de l'exécuter.
|
||||
CLEAN_SETUP # Appel la fonction de nettoyage spécifique du script install.
|
||||
fi
|
||||
|
||||
# Compense le bug de ssowat qui ne supprime pas l'entrée de l'app en cas d'erreur d'installation.
|
||||
sudo sed -i "\@\"$domain$path/\":@d" /etc/ssowat/conf.json
|
||||
|
||||
ynh_die
|
||||
}
|
||||
|
||||
TRAP_ON () { # Activate signal capture
|
||||
set -eu # Exit if a command fail, and if a variable is used unset.
|
||||
trap EXIT_PROPERLY EXIT # Capturing exit signals on shell script
|
||||
}
|
||||
|
||||
CHECK_USER () { # Vérifie la validité de l'user admin
|
||||
# $1 = Variable de l'user admin.
|
||||
ynh_user_exists "$1" || (echo "Wrong admin" >&2 && false)
|
||||
}
|
||||
|
||||
CHECK_PATH () { # Vérifie la présence du / en début de path. Et son absence à la fin.
|
||||
if [ "${path:0:1}" != "/" ]; then # Si le premier caractère n'est pas un /
|
||||
path="/$path" # Ajoute un / en début de path
|
||||
|
@ -16,7 +46,7 @@ CHECK_PATH () { # Vérifie la présence du / en début de path. Et son absence
|
|||
}
|
||||
|
||||
CHECK_DOMAINPATH () { # Vérifie la disponibilité du path et du domaine.
|
||||
sudo yunohost app checkurl $domain$path -a $app
|
||||
sudo yunohost app checkurl $domain$path -a $app || ynh_die "Path not available: ${domain}${path}"
|
||||
}
|
||||
|
||||
CHECK_FINALPATH () { # Vérifie que le dossier de destination n'est pas déjà utilisé.
|
||||
|
@ -27,3 +57,157 @@ CHECK_FINALPATH () { # Vérifie que le dossier de destination n'est pas déjà u
|
|||
false
|
||||
fi
|
||||
}
|
||||
|
||||
GENERATE_DB () { # Créer une base de données et un utilisateur dédié au nom de l'app.
|
||||
# $1 = Nom de la base de donnée
|
||||
db_user=$1
|
||||
db_user=${db_user//-/_} # mariadb ne supporte pas les - dans les noms de base de données. Ils sont donc remplacé par des _
|
||||
# Génère un mot de passe aléatoire.
|
||||
# db_pwd=$(head -n20 /dev/urandom | tr -c -d 'A-Za-z0-9' | head -c20)
|
||||
db_pwd=$(ynh_string_random)
|
||||
CHECK_VAR "$db_pwd" "db_pwd empty"
|
||||
# Utilise '$app' comme nom d'utilisateur et de base de donnée
|
||||
# Initialise la base de donnée et stocke le mot de passe mysql.
|
||||
ynh_mysql_create_db "$db_user" "$db_user" $db_pwd
|
||||
ynh_app_setting_set $app mysqlpwd $db_pwd
|
||||
}
|
||||
|
||||
SETUP_SOURCE () { # Télécharge la source, décompresse et copie dans $final_path
|
||||
# $1 = Nom de l'archive téléchargée.
|
||||
wget -nv -i ../sources/source_url -O $1
|
||||
# Vérifie la somme de contrôle de la source téléchargée.
|
||||
md5sum -c ../sources/source_md5 --status || (echo "Corrupt source" >&2 && false)
|
||||
# Décompresse la source
|
||||
if [ "$(echo ${1##*.})" == "gz" ]; then
|
||||
tar -x -f $1
|
||||
elif [ "$(echo ${1##*.})" == "zip" ]; then
|
||||
unzip -q $1
|
||||
else
|
||||
false # Format d'archive non pris en charge.
|
||||
fi
|
||||
# Copie les fichiers sources
|
||||
sudo cp -a $(cat ../sources/source_dir)/. "$final_path"
|
||||
# Copie les fichiers additionnels ou modifiés.
|
||||
if test -e "../sources/ajouts"; then
|
||||
sudo cp -a ../sources/ajouts/. "$final_path"
|
||||
fi
|
||||
}
|
||||
|
||||
ADD_SYS_USER () { # Créer un utilisateur système dédié à l'app
|
||||
if ! ynh_system_user_exists "$app" # Test l'existence de l'utilisateur
|
||||
then
|
||||
sudo useradd -d /var/www/$app --system --user-group $app --shell /usr/sbin/nologin || (echo "Unable to create $app system account" >&2 && false)
|
||||
fi
|
||||
}
|
||||
|
||||
POOL_FPM () { # Créer le fichier de configuration du pool php-fpm et le configure.
|
||||
sed -i "s@__NAMETOCHANGE__@$app@g" ../conf/php-fpm.conf
|
||||
sed -i "s@__FINALPATH__@$final_path@g" ../conf/php-fpm.conf
|
||||
sed -i "s@__USER__@$app@g" ../conf/php-fpm.conf
|
||||
finalphpconf=/etc/php5/fpm/pool.d/$app.conf
|
||||
sudo cp ../conf/php-fpm.conf $finalphpconf
|
||||
sudo chown root: $finalphpconf
|
||||
finalphpini=/etc/php5/fpm/conf.d/20-$app.ini
|
||||
sudo cp ../conf/php-fpm.ini $finalphpini
|
||||
sudo chown root: $finalphpini
|
||||
sudo service php5-fpm reload
|
||||
}
|
||||
|
||||
STORE_MD5_CONFIG () { # Enregistre la somme de contrôle du fichier de config
|
||||
# $1 = Nom du fichier de conf pour le stockage dans settings.yml
|
||||
# $2 = Nom complet et chemin du fichier de conf.
|
||||
ynh_app_setting_set $app $1_file_md5 $(sudo md5sum "$2" | cut -d' ' -f1)
|
||||
}
|
||||
|
||||
CHECK_MD5_CONFIG () { # Créé un backup du fichier de config si il a été modifié.
|
||||
# $1 = Nom du fichier de conf pour le stockage dans settings.yml
|
||||
# $2 = Nom complet et chemin du fichier de conf.
|
||||
if [ "$(ynh_app_setting_get $app $1_file_md5)" != $(sudo md5sum "$2" | cut -d' ' -f1) ]; then
|
||||
sudo cp -a "$2" "$2.backup.$(date '+%d.%m.%y_%Hh%M,%Ss')" # Si le fichier de config a été modifié, créer un backup.
|
||||
fi
|
||||
}
|
||||
|
||||
FIND_PORT () { # Cherche un port libre.
|
||||
# $1 = Numéro de port pour débuter la recherche.
|
||||
port=$1
|
||||
while ! sudo yunohost app checkport $port ; do
|
||||
port=$((port+1))
|
||||
done
|
||||
CHECK_VAR "$port" "port empty"
|
||||
}
|
||||
|
||||
|
||||
### REMOVE SCRIPT
|
||||
|
||||
REMOVE_NGINX_CONF () { # Suppression de la configuration nginx
|
||||
if [ -e "/etc/nginx/conf.d/$domain.d/$app.conf" ]; then # Delete nginx config
|
||||
echo "Delete nginx config"
|
||||
sudo rm "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
sudo service nginx reload
|
||||
fi
|
||||
}
|
||||
|
||||
REMOVE_FPM_CONF () { # Suppression de la configuration du pool php-fpm
|
||||
if [ -e "/etc/php5/fpm/pool.d/$app.conf" ]; then # Delete fpm config
|
||||
echo "Delete fpm config"
|
||||
sudo rm "/etc/php5/fpm/pool.d/$app.conf"
|
||||
fi
|
||||
if [ -e "/etc/php5/fpm/conf.d/20-$app.ini" ]; then # Delete php config
|
||||
echo "Delete php config"
|
||||
sudo rm "/etc/php5/fpm/conf.d/20-$app.ini"
|
||||
fi
|
||||
sudo service php5-fpm reload
|
||||
}
|
||||
|
||||
REMOVE_LOGROTATE_CONF () { # Suppression de la configuration de logrotate
|
||||
if [ -e "/etc/logrotate.d/$app" ]; then
|
||||
echo "Delete logrotate config"
|
||||
sudo rm "/etc/logrotate.d/$app"
|
||||
fi
|
||||
}
|
||||
|
||||
SECURE_REMOVE () { # Suppression de dossier avec vérification des variables
|
||||
chaine="$1" # L'argument doit être donné entre quotes simple '', pour éviter d'interpréter les variables.
|
||||
no_var=0
|
||||
while (echo "$chaine" | grep -q '\$') # Boucle tant qu'il y a des $ dans la chaine
|
||||
do
|
||||
no_var=1
|
||||
global_var=$(echo "$chaine" | cut -d '$' -f 2) # Isole la première variable trouvée.
|
||||
only_var=\$$(expr "$global_var" : '\([A-Za-z0-9_]*\)') # Isole complètement la variable en ajoutant le $ au début et en gardant uniquement le nom de la variable. Se débarrasse surtout du / et d'un éventuel chemin derrière.
|
||||
real_var=$(eval "echo ${only_var}") # `eval "echo ${var}` permet d'interpréter une variable contenue dans une variable.
|
||||
if test -z "$real_var" || [ "$real_var" = "/" ]; then
|
||||
echo "Variable $only_var is empty, suppression of $chaine cancelled." >&2
|
||||
return 1
|
||||
fi
|
||||
chaine=$(echo "$chaine" | sed "s@$only_var@$real_var@") # remplace la variable par sa valeur dans la chaine.
|
||||
done
|
||||
if [ "$no_var" -eq 1 ]
|
||||
then
|
||||
if [ -e "$chaine" ]; then
|
||||
echo "Delete directory $chaine"
|
||||
sudo rm -r "$chaine"
|
||||
fi
|
||||
return 0
|
||||
else
|
||||
echo "No detected variable." >&2
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
REMOVE_BDD () { # Suppression de la base de donnée et de l'utilisateur associé.
|
||||
# $1 = Nom de la base de donnée
|
||||
# Utilise '$app' comme nom d'utilisateur et de base de donnée
|
||||
db_user=$1
|
||||
if mysqlshow -u root -p$(sudo cat $MYSQL_ROOT_PWD_FILE) | grep -q "^| $db_user"; then
|
||||
echo "Delete db"
|
||||
ynh_mysql_drop_db $db_user
|
||||
ynh_mysql_drop_user $db_user
|
||||
fi
|
||||
}
|
||||
|
||||
REMOVE_SYS_USER () { # Supprime l'utilisateur système dédié à l'app
|
||||
if ynh_system_user_exists "$app" # Test l'existence de l'utilisateur
|
||||
then
|
||||
sudo userdel $app
|
||||
fi
|
||||
}
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
#!/bin/bash
|
||||
|
||||
source /usr/share/yunohost/helpers
|
||||
source ./_common
|
||||
source .fonctions
|
||||
set -eu
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
# Retrieve app id
|
||||
app=abantecart
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
# Retrieve arguments
|
||||
domain=$1
|
||||
path=$2
|
||||
is_public=$3
|
||||
user=$4
|
||||
passwd=$5
|
||||
email=$6
|
||||
domain=$YNH_APP_ARG_DOMAIN
|
||||
path=$YNH_APP_ARG_PATH
|
||||
is_public=$YNH_APP_ARG_IS_PUBLIC
|
||||
user=$YNH_APP_ARG_USER
|
||||
passwd=$YNH_APP_ARG_PASSWD
|
||||
email=$YNH_APP_ARG_EMAIL
|
||||
|
||||
script_dir=$PWD
|
||||
|
||||
|
@ -28,8 +28,12 @@ CHECK_DOMAINPATH # Vérifie la disponibilité du path et du domaine.
|
|||
CHECK_FINALPATH # Vérifie que le dossier de destination n'est pas déjà utilisé.
|
||||
|
||||
# Install dependency to convert tracks to a readable format for the browser
|
||||
sudo apt-get update
|
||||
sudo apt-get -y -qq install php5-mysql
|
||||
# sudo apt-get update
|
||||
# sudo apt-get -y -qq install php5-mysql
|
||||
|
||||
# Install dependencies using Helpers
|
||||
ynh_package_install_from_equivs ../conf/abantecart-deps.control \
|
||||
|| ynh_die "Unable to install dependencies"
|
||||
|
||||
# Check password strength
|
||||
[[ ${#passwd} -gt 5 ]] || ynh_die \
|
||||
|
@ -59,7 +63,14 @@ fi
|
|||
|
||||
# Copy files to the right place
|
||||
final_path=/var/www/$app
|
||||
sudo git clone https://github.com/abantecart/abantecart-src.git /var/www/$app
|
||||
|
||||
# We download the sources and check the md5sum
|
||||
SFILE=`sudo cat ../sources/source_file`;
|
||||
sudo wget -nv -i ../sources/source_url -O ${SFILE}.tar.gz
|
||||
sudo md5sum -c ../sources/source_md5 --status || (echo "Corrupt source" >&2 && false)
|
||||
sudo tar xvf ${SFILE}.tar.gz -C ../sources/
|
||||
sudo cp -a ../sources/abantecart-src-master/. $final_path
|
||||
|
||||
sudo rm -rf $final_path/tests
|
||||
sudo rm -rf $final_path/install.txt
|
||||
sudo mv $final_path/public_html/* $final_path/
|
||||
|
@ -85,35 +96,34 @@ popd
|
|||
# file owned by www-data before checking permissions
|
||||
sudo chown www-data:www-data $final_path -R
|
||||
|
||||
# Files owned by root, www-data can just read
|
||||
sudo chmod 0777 $final_path/system/config.php
|
||||
sudo chmod 0777 $final_path/system/
|
||||
sudo chmod 0777 $final_path/system/cache/ -R
|
||||
sudo chmod 0777 $final_path/system/logs/ -R
|
||||
sudo chmod 0777 $final_path/image/ -R
|
||||
sudo chmod 0777 $final_path/image/thumbnails/ -R
|
||||
sudo chmod 0777 $final_path/download/ -R
|
||||
sudo chmod 0777 $final_path/extensions/ -R
|
||||
sudo chmod 0777 $final_path/resources/ -R
|
||||
|
||||
# set database configuration
|
||||
sed -i "s@YNH_WWW_PATH@$path@g" ../conf/nginx.conf
|
||||
|
||||
# Modify Nginx configuration file and copy it to Nginx conf directory
|
||||
sed -i "s@YNH_WWW_PATH@$path@g" ../conf/nginx.conf
|
||||
sed -i "s@YNH_WWW_PATH@$path@g" ../conf/nginx.conf
|
||||
sed -i "s@YNH_WWW_ALIAS@$final_path/@g" ../conf/nginx.conf
|
||||
sudo sed -i "s@NAMETOCHANGE@$app@g" ../conf/nginx.conf
|
||||
nginxconf=/etc/nginx/conf.d/$domain.d/$app.conf
|
||||
sudo cp ../conf/nginx.conf $nginxconf
|
||||
sudo chown root: $nginxconf
|
||||
sudo chmod 600 $nginxconf
|
||||
sudo chmod 644 $nginxconf
|
||||
|
||||
sudo yunohost app setting $app is_public -v "$is_public"
|
||||
sudo sed -i "s@NAMETOCHANGE@$app@g" ../conf/php-fpm.conf
|
||||
sudo sed -i "s@FOLDERTOCHANGE@$final_path@g" ../conf/php-fpm.conf
|
||||
finalphpconf=/etc/php5/fpm/pool.d/$app.conf
|
||||
sudo cp ../conf/php-fpm.conf $finalphpconf
|
||||
sudo chown root:root $finalphpconf
|
||||
sudo chmod 644 $finalphpconf
|
||||
|
||||
|
||||
ynh_app_setting_set "$app" is_public "$is_public"
|
||||
if [ "$is_public" = "Yes" ];
|
||||
then
|
||||
sudo yunohost app setting $app unprotected_uris -v "/"
|
||||
ynh_app_setting_set "$app" unprotected_uris "/"
|
||||
fi
|
||||
|
||||
sudo rm -rf /var/www/$app/install/
|
||||
|
||||
sudo service php5-fpm reload
|
||||
sudo service nginx reload
|
||||
sudo yunohost app ssowatconf
|
||||
|
|
|
@ -4,12 +4,22 @@ app=$YNH_APP_INSTANCE_NAME
|
|||
set -u
|
||||
# Source app helpers
|
||||
source /usr/share/yunohost/helpers
|
||||
source .fonctions
|
||||
|
||||
domain=$(ynh_app_setting_get $app domain)
|
||||
|
||||
ynh_mysql_drop_db $app
|
||||
|
||||
sudo rm -rf /var/www/$app
|
||||
sudo rm -f /etc/nginx/conf.d/$domain.d/$app.conf
|
||||
# Remove installed files
|
||||
SECURE_REMOVE '/var/www/${app}'
|
||||
REMOVE_NGINX_CONF
|
||||
REMOVE_FPM_CONF
|
||||
|
||||
|
||||
# Remove app dependencies
|
||||
if ynh_package_is_installed "abantecart-deps"; then
|
||||
ynh_package_autoremove "abantecart-deps"
|
||||
fi
|
||||
|
||||
|
||||
sudo service nginx reload
|
||||
|
|
1
sources/source_file
Normal file
1
sources/source_file
Normal file
|
@ -0,0 +1 @@
|
|||
AbanteCart_1.2.9
|
1
sources/source_md5
Normal file
1
sources/source_md5
Normal file
|
@ -0,0 +1 @@
|
|||
73cec9b57291e022599d83a403510c22 AbanteCart_1.2.9.tar.gz
|
1
sources/source_upgrade
Normal file
1
sources/source_upgrade
Normal file
|
@ -0,0 +1 @@
|
|||
https://github.com/abantecart/abantecart-src/releases/download/1.2.9/abantecart_1.2.9_upgrade_only.tar.gz
|
1
sources/source_url
Normal file
1
sources/source_url
Normal file
|
@ -0,0 +1 @@
|
|||
https://github.com/abantecart/abantecart-src/releases/download/1.2.9/AbanteCart_1.2.9.tar.gz
|
Loading…
Reference in a new issue