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.
 
 

122 lines
2.4 KiB

#!/bin/bash
source "$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." &> /dev/null && pwd)/etc/config"
source "$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." &> /dev/null && pwd)/etc/projects"
function usage {
echo
echoMainTitle "Removes a project"
echo
echoSubTitle "Usage:"
echo
echo "remove-project [shortname]"
echo
echo "This will remove the project and move the project files to ./.trash"
echo
echo "--help Prints this message"
echo
}
help="$(getParameter "--help" false "$@")"
if [ "$help" == true ] || [ "$1" == "" ]
then
usage
exit
fi
shortname="$(getArgument "$1" "$(usage)" true)"
customer="$(getCustomerFromShortname "$shortname")"
project="$(getProjectFromShortname "$shortname")"
index=false
for i in "${!shortnames[@]}"
do
if [ "${shortnames[$i]}" == "$shortname" ]
then
index="$i"
fi
done
if [ "$index" == false ]
then
echo
echoError "Could not find project: $shortname"
echo
exit
fi
echo
echoMainTitle "Remove project"
echo
echoSubTitle "Please verify data"
echo
echo "Project Path: $workspaces_dir/$customer/$project"
echo "Project Data Path: $project_manager_dir/data/$customer/$project"
echo
confirm
nr=0
projects_string='';
for i in "${!projects[@]}"
do
if [ "$i" != "$index" ]
then
((nr=nr+1))
projects_string+="$(echo -e "\n\t\"${projects[$i]}\" # $nr")"
fi
done
nr=0
shortnames_string='';
for i in "${!shortnames[@]}"
do
if [ "$i" != "$index" ]
then
((nr=nr+1))
shortnames_string+="$(echo -e "\n\t\"${shortnames[$i]}\" # $nr")"
fi
done
nr=0
customers_string='';
for i in "${!customers[@]}"
do
if [ "$i" != "$index" ]
then
((nr=nr+1))
customers_string+="$(echo -e "\n\t\"${customers[$i]}\" # $nr")"
fi
done
cat <<- EOF > "$project_manager_dir/etc/projects"
#!/bin/bash
projects=($projects_string
)
shortnames=($shortnames_string
)
customers=($customers_string
)
EOF
echo
echo "Moving files to trash"
rand=$(cat /proc/sys/kernel/random/uuid)
trash_path="$project_manager_dir/.trash/$rand"
mkdir "$trash_path"
mkdir "$trash_path/data"
mkdir "$trash_path/workspace"
mv "$project_manager_dir/data/$customer" "$trash_path/data/$customer"
mv "$workspaces_dir/$customer" "$trash_path/workspace/$customer"
echo
echoSubTitle "Running postscripts ..."
postScript "$path/bin/postscripts/commands/remove-project"
postScript "$workspaces_dir/$customer/$project/bin/postscripts/commands/remove-project"
echo
echoSuccess "Project has been remove, (moved to ./.trash)"
echo