Merge pull request #36 from YunoHost/pre_install

Pre install
This commit is contained in:
Maniack Crudelis 2017-10-24 21:40:31 +02:00 committed by GitHub
commit 228345bc0e
6 changed files with 49 additions and 3 deletions

View file

@ -50,6 +50,9 @@ package_check/package_check.sh APP_ynh
```
;; Nom du test
# Commentaire ignoré
; pre-install
echo -n "Placez ici vos commandes a exéxuter dans le conteneur, "
echo "avant chaque installation de l'application."
; Manifest
domain="domain.tld" (DOMAIN)
path="/path" (PATH)
@ -91,6 +94,11 @@ Nom du scénario de test qui sera effectué.
On peut créer autant de scénario de test que voulu, tous ayant la même syntaxe.
Les différents scénarios de test seront exécutés successivement.
### `; pre-install`
*Instruction optionnelle*
Si vous devez exécuter une commande ou un groupe de commandes avant l'installation, vous pouvez utiliser cette instruction.
Toutes les commandes ajoutées après l'instruction `; pre-install` seront exécutées dans le conteneur avant chaque installation de l'application.
### `; Manifest`
Ensemble des clés du manifest.
Toutes les clés du manifest doivent être renseignée afin de procéder à l'installation.

View file

@ -50,6 +50,9 @@ package_check/package_check.sh APP_ynh
```
;; Test name
# Comment ignored
; pre-install
echo -n "Here your commands to execute in the container, "
echo "before each installation of the app."
; Manifest
domain="domain.tld" (DOMAIN)
path="/path" (PATH)
@ -91,6 +94,11 @@ Name of tests series that will be perform.
It's possible to create multiples tests series, all with the same syntax.
All different tests series will be perform sequentialy.
### `; pre-install`
*Optionnal instruction*
If you have to execute a command or a group of commands before the installation. You can use this instruction.
All the commands added after the instruction `; pre-install` will be executed in the container before each installation of the app.
### `; Manifest`
Set of manifest keys.
All manifest keys need to be filled to perform installation.

View file

@ -1,5 +1,8 @@
;; Nom du test
# Commentaire ignoré
; pre-install
echo -n "Here your commands to execute in the container"
echo ", before each installation of the app."
; Manifest
domain="domain.tld" (DOMAIN)
path="/path" (PATH)

View file

@ -840,7 +840,7 @@ then
break;
fi
# Copy the line in the partial check_process
echo $line >> "$partial_check_process"
echo "$line" >> "$partial_check_process"
fi
# Search for the first line
@ -899,9 +899,14 @@ then
# Extract the section of the current tests serie
extract_section "^$tests_serie" "^;;" "$check_process"
partial_check_process=$partial1
# Check if there a pre-install instruction for this serie
extract_section "^; pre-install" "^;" "$partial2"
pre_install="$(cat "$partial_check_process")"
# Parse all infos about arguments of manifest
# Extract the manifest arguments section from the second partial file
partial_check_process=$partial1
extract_section "^; Manifest" "^; " "$partial2"
# Initialize the arguments list

View file

@ -38,4 +38,4 @@ echo "Pour établir une connexion ssh:"
if [ $(cat "$script_dir/setup_user") = "root" ]; then
echo -ne "\e[1msudo "
fi
echo -e "\e[1mssh -t $LXC_NAME\e[0m"
echo -e "\e[1mssh -t $LXC_NAME 'bash -i'\e[0m"

View file

@ -31,6 +31,28 @@ SETUP_APP () {
# Uses the default snapshot
current_snapshot=snap0
# Exec the pre-install instruction, if there one
if [ -n "$pre_install" ]
then
ECHO_FORMAT "Pre installation request\n" "white" "bold" clog
# Start the lxc container
LXC_START "true"
# Copy all the instructions into a script
echo "$pre_install" > "$script_dir/preinstall.sh"
chmod +x "$script_dir/preinstall.sh"
# Replace variables
sed -i "s/\$USER/$test_user/" "$script_dir/preinstall.sh"
sed -i "s/\$DOMAIN/$main_domain/" "$script_dir/preinstall.sh"
sed -i "s/\$SUBDOMAIN/$sub_domain/" "$script_dir/preinstall.sh"
sed -i "s/\$PASSWORD/$yuno_pwd/" "$script_dir/preinstall.sh"
# Copy the pre-install script into the container.
scp -rq "$script_dir/preinstall.sh" "$lxc_name":
# Then execute the script to execute the pre-install commands.
LXC_START "./preinstall.sh >&2"
# Print the log to print the results
ECHO_FORMAT "$(cat "$temp_log")\n" clog
fi
# Install the application in a LXC container
LXC_START "sudo yunohost --debug app install \"$package_dir\" -a \"$manifest_args_mod\""