From 33f261d8583de6f9b41b9c33dd15a034a48c5c06 Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Fri, 20 Oct 2017 22:36:37 +0200 Subject: [PATCH 1/2] Add pre-install script feature --- check_process | 3 +++ package_check.sh | 9 +++++++-- sub_scripts/lxc_force_start.sh | 2 +- sub_scripts/testing_process.sh | 22 ++++++++++++++++++++++ 4 files changed, 33 insertions(+), 3 deletions(-) diff --git a/check_process b/check_process index 56fb1ca..a92e6da 100644 --- a/check_process +++ b/check_process @@ -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) diff --git a/package_check.sh b/package_check.sh index 1f306ce..d9e79f3 100755 --- a/package_check.sh +++ b/package_check.sh @@ -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 diff --git a/sub_scripts/lxc_force_start.sh b/sub_scripts/lxc_force_start.sh index f7d3607..8aa9680 100755 --- a/sub_scripts/lxc_force_start.sh +++ b/sub_scripts/lxc_force_start.sh @@ -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" diff --git a/sub_scripts/testing_process.sh b/sub_scripts/testing_process.sh index ee32e47..77c08a3 100644 --- a/sub_scripts/testing_process.sh +++ b/sub_scripts/testing_process.sh @@ -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\"" From 2ec5834a98da25cb4a9c93ea4284af986709cb3d Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Tue, 24 Oct 2017 21:32:39 +0200 Subject: [PATCH 2/2] Update readme --- README-fr.md | 8 ++++++++ README.md | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/README-fr.md b/README-fr.md index 5e13978..0c38b71 100644 --- a/README-fr.md +++ b/README-fr.md @@ -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. diff --git a/README.md b/README.md index ce510aa..9ed3ce3 100644 --- a/README.md +++ b/README.md @@ -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.