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.
301 lines
7.9 KiB
301 lines
7.9 KiB
#!/bin/bash
|
|
|
|
### DO NOT EDIT THIS FILE
|
|
|
|
if [ true != ${includes_project_manager:-false} ]
|
|
then
|
|
includes_project_manager=true
|
|
|
|
function getProjectFromShortname {
|
|
local shortname="$(getArgument "$1")"
|
|
for i in "${!project_manager_shortnames[@]}"
|
|
do
|
|
if [ "${project_manager_shortnames[$i]}" == "$shortname" ]
|
|
then
|
|
echo "${project_manager_projects[$i]}"
|
|
fi
|
|
done
|
|
}
|
|
|
|
function getCustomerFromShortname {
|
|
local shortname="$(getArgument "$1")"
|
|
for i in "${!project_manager_shortnames[@]}"
|
|
do
|
|
if [ "${project_manager_shortnames[$i]}" == "$shortname" ]
|
|
then
|
|
echo "${project_manager_customers[$i]}"
|
|
fi
|
|
done
|
|
}
|
|
|
|
function loadProjectConfig
|
|
{
|
|
local shortname="$(getArgument "$1")"
|
|
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"
|
|
source "$path/etc/config"
|
|
}
|
|
|
|
function loadPluginConfig
|
|
{
|
|
local shortname="$(getArgument "$1")"
|
|
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")"
|
|
|
|
for plugin in ${plugins[*]}
|
|
do
|
|
if [ -f "$path/etc/plugins/$plugin/config" ]
|
|
then
|
|
source "$path/etc/plugins/$plugin/config"
|
|
fi
|
|
done
|
|
}
|
|
|
|
function makeProjectManagerDirectories {
|
|
local shortname="$(getArgument "$1")"
|
|
local customer="$(getArgument "$2")"
|
|
local project="$(getArgument "$3")"
|
|
|
|
path="$project_manager_dir/data/$customer/$project"
|
|
|
|
if [ ! -d "$path" ]; then mkdir -p "$path"; fi
|
|
if [ ! -d "$path/.ssh" ]; then mkdir "$path/.ssh"; fi
|
|
if [ ! -d "$path/backup" ]; then mkdir "$path/backup"; fi
|
|
if [ ! -d "$path/backup/database" ]; then mkdir "$path/backup/database"; fi
|
|
if [ ! -d "$path/bin" ]; then mkdir "$path/bin"; fi
|
|
if [ ! -d "$path/bin/postscripts" ]; then mkdir "$path/bin/postscripts"; fi
|
|
if [ ! -d "$path/bin/postscripts/plugins" ]; then mkdir "$path/bin/postscripts/plugins"; fi
|
|
if [ ! -d "$path/bin/includes" ]; then mkdir "$path/bin/includes"; fi
|
|
if [ ! -d "$path/bin/includes/plugins" ]; then mkdir "$path/bin/includes/plugins"; fi
|
|
if [ ! -d "$path/etc" ]; then mkdir "$path/etc"; fi
|
|
if [ ! -d "$path/etc/plugins" ]; then mkdir "$path/etc/plugins"; fi
|
|
if [ ! -d "$path/shared" ]; then mkdir "$path/shared"; fi
|
|
if [ ! -d "$path/shared/live" ]; then mkdir "$path/shared/live"; fi
|
|
if [ ! -d "$path/shared/stage" ]; then mkdir "$path/shared/stage"; fi
|
|
if [ ! -d "$path/var" ]; then mkdir "$path/var"; fi
|
|
if [ ! -d "$path/var/tmp" ]; then mkdir "$path/var/tmp"; fi
|
|
if [ ! -d "$path/var/latest" ]; then mkdir "$path/var/latest"; fi
|
|
}
|
|
|
|
function makeWorkspaceDirectories {
|
|
local shortname="$(getArgument "$1")"
|
|
local customer="$(getArgument "$2")"
|
|
local project="$(getArgument "$3")"
|
|
|
|
if [ ! -d "$project_manager_workspaces_dir/$customer/$project" ]; then mkdir -p "$project_manager_workspaces_dir/$customer/$project"; fi
|
|
}
|
|
|
|
function addProjectConfig {
|
|
local shortname="$(getArgument "$1")"
|
|
local customer="$(getArgument "$2")"
|
|
local project="$(getArgument "$3")"
|
|
|
|
_addProject "$project"
|
|
_addCustomer "$customer"
|
|
_addShortname "$shortname"
|
|
}
|
|
|
|
function hasShortname {
|
|
local shortname="$(getArgument "$1")"
|
|
|
|
for i in "${!project_manager_shortnames[@]}"
|
|
do
|
|
if [ "${project_manager_shortname[$i]}" == "$shortname" ]
|
|
then
|
|
echo true
|
|
fi
|
|
done
|
|
echo false
|
|
}
|
|
|
|
function hasProject {
|
|
local project="$(getArgument "$1")"
|
|
|
|
for i in "${!project_manager_projects[@]}"
|
|
do
|
|
if [ "${project_manager_projects[$i]}" == "$project" ]
|
|
then
|
|
echo true
|
|
fi
|
|
done
|
|
echo false
|
|
}
|
|
|
|
function _addShortname {
|
|
local shortname="$(getArgument "$1")"
|
|
local hasShortname="$(hasShortname "$shortname")"
|
|
|
|
if [ "$hasShortname" == true ]
|
|
then
|
|
echo
|
|
echoError "Shortname already exists"
|
|
echo
|
|
exit
|
|
fi
|
|
|
|
local string='';
|
|
for i in "${!project_manager_shortnames[@]}"
|
|
do
|
|
string+="$(echo -e "\n\t'${project_manager_shortnames[$i]}'")"
|
|
done
|
|
string+="$(echo -e "\n\t'$shortname'")"
|
|
_writeShortnames "$string"
|
|
}
|
|
|
|
function _addProject {
|
|
local project="$(getArgument "$1")"
|
|
local hasProject="$(hasProject "$project")"
|
|
|
|
if [ "$hasProject" == true ]
|
|
then
|
|
echo
|
|
echoError "Project already exists"
|
|
echo
|
|
exit
|
|
fi
|
|
|
|
local string='';
|
|
for i in "${!project_manager_projects[@]}"
|
|
do
|
|
string+="$(echo -e "\n\t'${project_manager_projects[$i]}'")"
|
|
done
|
|
string+="$(echo -e "\n\t'$project'")"
|
|
_writeProjects "$string"
|
|
}
|
|
|
|
function _addCustomer {
|
|
local customer="$(getArgument "$1")"
|
|
|
|
local string='';
|
|
for i in "${!project_manager_customers[@]}"
|
|
do
|
|
string+="$(echo -e "\n\t'${project_manager_customers[$i]}'")"
|
|
done
|
|
string+="$(echo -e "\n\t'$customer'")"
|
|
_writeCustomers "$string"
|
|
}
|
|
|
|
function _writeShortnames {
|
|
local string="$(getArgument "$1")"
|
|
cat <<- EOF > "$project_manager_dir/etc/shortnames"
|
|
#!/bin/bash
|
|
|
|
project_manager_shortnames=($string
|
|
)
|
|
EOF
|
|
}
|
|
|
|
function _writeCustomers {
|
|
local string="$(getArgument "$1")"
|
|
cat <<- EOF > "$project_manager_dir/etc/customers"
|
|
#!/bin/bash
|
|
|
|
project_manager_customers=($string
|
|
)
|
|
EOF
|
|
}
|
|
|
|
function _writeProjects {
|
|
local string="$(getArgument "$1")"
|
|
cat <<- EOF > "$project_manager_dir/etc/projects"
|
|
#!/bin/bash
|
|
|
|
project_manager_projects=($string
|
|
)
|
|
EOF
|
|
}
|
|
|
|
function removeProjectConfig {
|
|
local shortname="$(getArgument "$1")"
|
|
local pos="$(getProjectConfigPosition "$shortname")"
|
|
|
|
_removeShortname "$pos"
|
|
_removeCustomer "$pos"
|
|
_removeProject "$pos"
|
|
}
|
|
|
|
function getProjectConfigPosition {
|
|
local shortname="$(getArgument "$1")"
|
|
|
|
for i in "${!project_manager_shortnames[@]}"
|
|
do
|
|
if [ "${$project_manager_shortnames[$i]}" == "$shortname" ]
|
|
then
|
|
((ret=i+1))
|
|
return "$ret"
|
|
fi
|
|
done
|
|
return 0
|
|
}
|
|
|
|
function _removeShortname {
|
|
local pos="$(getArgument "$1")"
|
|
|
|
local string='';
|
|
for i in "${!project_manager_shortnames[@]}"
|
|
do
|
|
((nr=i+1))
|
|
if [ "$pos" == "$nr" ]
|
|
then
|
|
continue
|
|
fi
|
|
string+="$(echo -e "\n\t'${project_manager_shortnames[$i]}'")"
|
|
done
|
|
_writeShortnames "$string"
|
|
}
|
|
|
|
function _removeProjects {
|
|
local pos="$(getArgument "$1")"
|
|
|
|
local string='';
|
|
for i in "${!project_manager_projects[@]}"
|
|
do
|
|
((nr=i+1))
|
|
if [ "$pos" == "$nr" ]
|
|
then
|
|
continue
|
|
fi
|
|
string+="$(echo -e "\n\t'${project_manager_projects[$i]}'")"
|
|
done
|
|
_writeProjects "$string"
|
|
}
|
|
|
|
function _removeCustomer {
|
|
local pos="$(getArgument "$1")"
|
|
|
|
local string='';
|
|
for i in "${!project_manager_customers[@]}"
|
|
do
|
|
((nr=i+1))
|
|
if [ "$pos" == "$nr" ]
|
|
then
|
|
continue
|
|
fi
|
|
string+="$(echo -e "\n\t'${project_manager_customers[$i]}'")"
|
|
done
|
|
_writeCustomers "$string"
|
|
}
|
|
|
|
fi
|