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.
 
 

151 lines
3.4 KiB

#!/bin/bash
set -e
project_manager_dir="$(readlink -f "$(dirname "$(readlink -f ${BASH_SOURCE[0]})")/..")"
source "$project_manager_dir/bin/includes/includes"
if [ -f "$project_manager_dir/etc/config" ]
then
source "$project_manager_dir/etc/config"
fi
if [ -f "$project_manager_dir/etc/projects" ]
then
source "$project_manager_dir/etc/projects"
fi
function use {
echo
echoMainTitle "Sumedia Project Manager"
echoSmall "Manager: $project_manager_dir"
echoSmall "Workspaces: $workspaces_dir"
echo
echoSubTitle "Usage:"
echo
echo "project-manager [command] [command-args]"
echo "project-manager [plugin:command] [command-args]"
echo
echo "--help Prints this message"
echo "--help [command] Prints the help message for a command"
echo "--help [plugin:command] Prints the help message for a command"
echo "--list-commands List all commands"
echo "--list-commands [plugin] List all plugin commands"
echo "--list-plugins List all plugins"
echo
}
function list {
local dir=$1
echo >&2
echoMainTitle "List" >&2
echo >&2
echoSubTitle "List $dir" >&2
echo >&2
dir=($(ls -t "$project_manager_dir/$dir"))
for script in "${dir[@]}"
do
echo "- $script" >&2
done
echo >&2
}
help="$(getParameter "--help" false "$*")"
list_commands="$(getParameter "--list-commands" false "$*")"
list_plugins="$(getParameter "--list-plugins" false "$*")"
if [[ "$1" == *"--"* ]]; then key=2; else key=1; fi
param="$(eval "echo \"\$${key}\"")"
if [[ "$param" == *":"* ]]
then
command="$(echo "$param" | cut -f2 -d':')"
plugin="$(echo "$param" | cut -f1 -d':')"
else
command=$param
plugin=""
fi
if [ ! -f "$project_manager_dir/etc/config" ] || [ ! -f "$project_manager_dir/etc/projects" ]
then
command="install-project-manager"
plugin=""
fi
if [ "$1" == "" ] && [ "command" == "" ]
then
use
exit
fi
if [ "$help" == true ] || [ "$list_commands" == true ] || [ "$list_plugins" == true ]
then
if [ "$command" == "" ] && [ "$list_commands" == false ] && [ "$list_plugins" == false ]
then
use
exit
elif [ "$command" != "" ] && [ "$plugin" != "" ] && [ "$help" == true ]
then
file="$project_manager_dir/plugins/$plugin/commands/$command"
if [ ! -f "$file" ]
then
echo
echoError "No such file or directory: $file"
echo
exit
else
source "$file" --help
exit
fi
elif [ "$command" != "" ] && [ "$help" == true ]
then
file="$project_manager_dir/bin/commands/$command"
if [ ! -f "$file" ]
then
echo
echoError "No such file or directory: $file"
echo
exit
else
source "$file" --help
exit
fi
elif [ "$command" != "" ] && [ "$list_commands" == true ]
then
list "plugins/$command/commands"
elif [ "$list_commands" == true ]
then
list "bin/commands"
elif [ "$list_plugins" == true ]
then
list "plugins"
fi
else
if [ "$plugin" != "" ]
then
file="$project_manager_dir/plugins/$plugin/commands/$command"
else
file="$project_manager_dir/bin/commands/$command"
fi
if [ ! -f "$file" ]
then
echo
echoError "No such file or directory: $file"
echo
exit
else
source "$file" "${@:2}"
fi
echo
echoSubTitle "Running postscripts ..."
postScript "$project_manager_dir/bin/postscripts/project-manager"
echo
echoSuccess "Project Manager done"
echo
fi