Commit 53557c43 authored by HgO's avatar HgO

Merge branch 'execute-custom-script' into 'master'

Execute custom script

Closes #9 and #12

See merge request !17
parents 61574e48 7192a1fb
#!/bin/bash
# Adding neutrinet specifics
main_domain=$(yunohost tools maindomain --output=plain)
yunohost app fetchlist -n neutrinet -u https://neutrinet.be/apps.json --debug
yunohost app fetchlist --debug
yunohost app install neutrinet --force --debug --args "domain=${main_domain}&path=/neutrinet"
......@@ -27,6 +27,8 @@
declare -A LOG_LEVELS=([DEBUG]=0 [INFO]=1 [WARN]=2 [ERROR]=3)
LOG_LEVEL=${LOG_LEVELS[INFO]}
CURRENT_SCRIPT_DIR="$(dirname $0)"
YNH_IMG_LOCATION="https://build.yunohost.org"
DEBIAN_CODENAME="stretch"
INTERNETCUBE_PREFIX="internetcube"
......@@ -51,6 +53,9 @@ INSTALL_SD_SCRIPT_NAME="install-sd.sh"
HYPERCUBE_FILE="install.hypercube"
CUSTOM_SCRIPT_PATH="${CURRENT_SCRIPT_DIR}/custom_neutrinet_specifics.sh"
EXECUTE_CUSTOM_SCRIPT=true
# See https://github.com/YunoHost/yunohost/blob/master/data/actionsmap/yunohost.yml#L104
LOGIN_PATTERN='^[a-z0-9_]+$'
# See https://github.com/YunoHost/yunohost/blob/master/data/actionsmap/yunohost.yml#L112
......@@ -644,6 +649,33 @@ EOF
info "$HYPERCUBE_FILE created!"
}
function add_custom_script() {
if confirm "Do you want to add Neutrinet's specifics to the installation?" "y"
then
info "Neutrinet's specifics script will be added when flashing the sd card"
else
location_has_error=true
while $location_has_error
do
if confirm "Would you like to add your own custom script?" "n"
then
read -e -r -p "Enter your custom script's location: " CUSTOM_SCRIPT_PATH
if [[ ! -f "$CUSTOM_SCRIPT_PATH" ]]
then
error "Either the location is wrong or it is not a regular file"
else
info "Your custom script will be added when flashing the sd card"
location_has_error=false
fi
else
info "No custom script will be added then"
EXECUTE_CUSTOM_SCRIPT=false
location_has_error=false
fi
done
fi
}
function get_image() {
echo -n "What hardware are you installing on? [lime/lime2]: "
board_has_error=true
......@@ -732,7 +764,12 @@ function flash_sd_card() {
download_install_sd_script
fi
"./$CUBE_RESOURCES_LOCATION/$INSTALL_SD_SCRIPT_NAME" -y "$HYPERCUBE_FILE" -f "$CUBE_RESOURCES_LOCATION/$image"
if $EXECUTE_CUSTOM_SCRIPT
then
"./$CUBE_RESOURCES_LOCATION/$INSTALL_SD_SCRIPT_NAME" -y "$HYPERCUBE_FILE" -f "$CUBE_RESOURCES_LOCATION/$image" -c "$CUSTOM_SCRIPT_PATH"
else
"./$CUBE_RESOURCES_LOCATION/$INSTALL_SD_SCRIPT_NAME" -y "$HYPERCUBE_FILE" -f "$CUBE_RESOURCES_LOCATION/$image"
fi
}
function prepare_cube() {
......@@ -849,6 +886,7 @@ set -e
show_welcome
check_dependencies
create_hypercube_file
add_custom_script
get_image
flash_sd_card
prepare_cube
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment