Ein für Shopware 6 vorbereitet Systemmanagment.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

216 lines
4.9 KiB

#!/bin/bash
### DO NOT EDIT THIS FILE
if [ true != ${includes_included:-false} ]
then
includes_included=true
function echoMainTitle {
echo -e "\033[38;5;214m$1\033[0m"
}
function echoSubTitle {
echo -e "\033[38;5;142m$1\033[0m"
}
function echoSmall {
echo -e "\033[38;5;240m$1\033[0m"
}
function echoSelect {
local select="$1"
local message="$2"
echo -e "\033[0;33m$select\033[0m $message"
}
function echoError {
echo -e "\033[0;91m$1\033[0m"
}
function echoWarning {
echo -e "\033[0;33m$1\033[0m"
}
function echoSuccess {
echo -e "\033[0;32m$1\033[0m"
}
function getParameter {
local name=$1
local has=$2
local parameters=($3)
for i in "${!parameters[@]}"
do
if [ "${parameters[$i]}" == "$name" ] && [ "$has" == true ]
then
((j=i+1))
echo "${parameters[$j]}"
elif [ "${parameters[$i]}" == "$name" ]
then
echo true
fi
done
}
function getArgument {
local errmsg=$2
local allow=${3:-false}
local var=$1
if [ "$allow" != false ] && [ "$(isAllowed "$var" "$allow")" == false ]
then
echo "$errmsg" >&2
exit 1
fi
echo "$var"
}
function isAllowed {
local var="$1"
local allow="$2"
local valid=true
if [ "$allow" == true ] && [ "$var" == "" ]
then
valid=false
elif [ "$allow" != false ] && [ "$allow" != true ]
then
allow=($allow)
local found=false
for i in "${!allow[@]}"
do
if [ "${allow[$i]}" == "$var" ]
then
found=true
fi
done
if [ "$found" != true ]
then
valid=false
fi
fi
echo $valid
}
function readConsole {
local message="$1"
local errmsg="$2"
local allow=${3:-false}
local default="$4"
if [ "$default" != "" ]
then
read -p "$message [default:$default]: " var
else
read -p "$message: " var
fi
if [ "$var" == "" ] && [ "$default" != "" ]
then
var="$default"
fi
if [ "$(isAllowed "$var" "$allow")" == false ]
then
echo "$errmsg" >&2
var=$(readConsole "$message" "$errmsg" "$allow" "$default")
fi
echo "$var"
}
function getProjectFromShortname {
local shortname="$(getArgument "$1" "Invalid Argument" true)"
for i in "${!shortnames[@]}"
do
if [ "${shortnames[$i]}" == "$shortname" ]
then
echo "${projects[$i]}"
fi
done
}
function getCustomerFromShortname {
local shortname="$(getArgument "$1" "Invalid Argument" true)"
for i in "${!shortnames[@]}"
do
if [ "${shortnames[$i]}" == "$shortname" ]
then
echo "${customers[$i]}"
fi
done
}
function loadProjectConfig
{
local shortname="$(getArgument "$1" "Invalid Argument" true)"
local customer="$(getCustomerFromShortname "$shortname")"
local project="$(getProjectFromShortname "$shortname")"
if [ "$customer" == "" ] || [ "$project" == "" ]
then
echo
echoError "Could not load project with name: $shortname"
echo
exit
fi
local path="$project_manager_dir/data/$customer/$project"
local plugin_path="$project_manager_dir/plugins"
local plugins="$(ls -t "$plugin_path")"
source "$path/etc/config"
for plugin in ${plugins[*]}
do
if [ -f "$path/etc/plugins/$plugin/config" ]
then
source "$path/etc/plugins/$plugin/config"
fi
done
}
function postScript {
local script=$(getArgument "$1" "Usage: postScript \"post_script.sh\"" true)
if [ -f "$script" ]
then
source "$script"
fi
}
function getConfig {
local env=$(getArgument "$1" "Usage getEnvVar [live|stage|local_live|local_stage] var" "live stage local_live local_stage")
local suffix=$(getArgument "$2" "Usage getEnvVar [live|stage|local_live|local_stage] var" true)
echo "$(eval "echo \"\$${env}_$suffix\"")"
}
function sedEscape {
echo "$1" | sed -r 's/([\$\.\*\/\[\\^])/\\\1/g' | sed 's/[]]/\[]]/g'
}
function confirm {
confirm="$(readConsole "Should i execute? [y,n]" "Invalid selection" "y n")"
if [ "$confirm" == "n" ]
then
echo
echoError "Aborting"
echo
exit
fi
}
plugin_dir="$project_manager_dir/plugins"
plugins="$(ls -t "$plugin_dir")"
for plugin in ${plugins[*]}
do
if [ -f "$plugin_dir/$plugin/includes/includes" ]
then
source "$plugin_dir/$plugin/includes/includes"
fi
done
fi