Browse Source

refactoring

master
Sven Ullmann 2 years ago
parent
commit
1864c93367
  1. 61
      plugins/plesk/bak/includes/includes
  2. 13
      plugins/plesk/src/commands/create-domain
  3. 7
      plugins/plesk/src/includes/bash_header
  4. 4
      src/includes/project_manager

61
plugins/plesk/bak/includes/includes

@ -1,61 +0,0 @@
#!/bin/bash
### DO NOT EDIT THIS FILE
plesk_included=true
function pleskValidate {
local env=$(getArgument "$1" "Usage: pleskValidate [live|stage]" "live stage")
if [ "$ssh_included" == "" ]
then
echo >&2
echoError "Plugin \"ssh\" has to be included" >&2
echo >&2
exit
fi
if [ "$db_included" == "" ]
then
echo >&2
echoError "Plugin \"db\" has to be included" >&2
echo >&2
exit
fi
if [ "$plesk_host" == "" ] || [ "$plesk_user" == "" ]
then
echo >&2
echoError "Please configure $project_manager_dir/data/$customer/$project/etc/plugins/plesk/config" >&2
echo >&2
exit
fi
if [ "$(dbGetConfig "$env" "user")" == "" ] || [ "$(dbGetConfig "$env" "database")" == "" ] || [ "$(dbGetConfig "$env" "password")" == "" ]
then
echo >&2
echoError "Please configure $project_manager_dir/data/$customer/$project/etc/plugins/db/config" >&2
echo >&2
exit
fi
}
function pleskAddSSHKey {
if [ ! -f "$plesk_private_key" ] && [ ! -f "$app_dir/.ssh/plesk" ]
then
sshGenerateKey "plesk"
sshCopyIdKey "plesk" "$plesk_user@$plesk_host" "$app_dir/.ssh/plesk.pub"
fi
if [ -f "$plesk_private_key" ] && [ ! -f "$app_dir/.ssh/plesk" ]
then
sshCopyKey "plesk" "$plesk_private_key"
fi
if [ -f "$plesk_public_key" ] && [ ! -f "$app_dir/.ssh/plesk.pub" ]
then
sshCopyKey "plesk.pub" "$plesk_private_key"
fi
ssh-add "$app_dir/.ssh/plesk"
}

13
plugins/plesk/src/commands/create-domain

@ -15,14 +15,15 @@ function usage {
}
source "$(cd "$(dirname "${BASH_SOURCE[0]}")/.." &> /dev/null && pwd)/includes/bash_header"
pleskName="$(getArgument "$2" "Plesk name required" true)"
domain="$(getArgument "$3" "Domain required" true)"
escapedPleskName=${pleskName//./\\.}
sshName="$(getConfig "$shortname" "plesk.servers.$escapedPleskName.ssh")"
escapeSSHName=${sshName//./\\.}
user="$(getConfig "$shortname" "ssh.servers.$escapeSSHName.user")"
host="$(getConfig "$shortname" "ssh.servers.$escapeSSHName.host")"
user="$(getConfig "$shortname" "ssh.servers.$escapeSSHName.port")"
escapedSSHName=${sshName//./\\.}
user="$(getConfig "$shortname" "ssh.servers.$escapedSSHName.user")"
host="$(getConfig "$shortname" "ssh.servers.$escapedSSHName.host")"
user="$(getConfig "$shortname" "ssh.servers.$escapedSSHName.port")"
echo
echoMainTitle "Adding domain on plesk server"
@ -30,14 +31,16 @@ echo
echoSubTitle "Please verify data"
echo
echo "Plesk: $pleskName"
echo "SSH Connection: $sshName"
echo
echo "User: $user"
echo "Host: $host"
echo
echo "Doman: $domain"
echo "Domain: $domain"
echo
confirm
sshAdd "$shortname" "$sshName"
ssh -p "$port" "$user@$host" "plesk bin site --create '$domain' -webspace-name '$domain' -hosting true"
echo

7
plugins/plesk/src/includes/bash_header

@ -2,9 +2,4 @@
### DO NOT EDIT THIS FILE
source "$project_manager_dir/src/includes/bash_header"
shortname="$(getArgument "$1" "shortname required" true)"
escapedShortname=${shortname//./\\.}
customer="$(getConfig false "project_manager.projects.$escapedShortname.customer")"
project="$(getConfig false "project_manager.projects.$escapedShortname.project")"
source "$project_manager_dir/src/includes/plugin_header"

4
src/includes/project_manager

@ -15,12 +15,12 @@ then
local target_config_dir="$project_manager_dir/data/$customer/$project/etc/$plugin"
local target_config_file="$target_config_dir/config.json"
if [ ! -d "$target_config_dir"]
if [ ! -d "$target_config_dir" ]
then
mkdir -p "$target_config_dir"
fi
if [ ! -f "$target_config_file"]
if [ ! -f "$target_config_file" ]
then
cp "$source_config_file" "$target_config_source_config_file"
fi

Loading…
Cancel
Save