Sven Ullmann
2 years ago
9 changed files with 247 additions and 30 deletions
-
5bin/project-manager
-
22etc/.config_template
-
7plugins/git/commands/clone
-
69plugins/plesk/commands/create-database
-
62plugins/plesk/commands/create-subdomain
-
10plugins/plesk/etc/.config_template
-
59plugins/plesk/includes/includes
-
5plugins/ssh/commands/add-key
-
36plugins/ssh/includes/includes
@ -0,0 +1,69 @@ |
|||
#!/bin/bash |
|||
|
|||
function usage { |
|||
echo |
|||
echoMainTitle "Creates a database on plesk server" |
|||
echo |
|||
echoSubTitle "Usage:" |
|||
echo |
|||
echo "project-manager plesk:create-database [project-shortname] [env]" |
|||
echo |
|||
echo " [env] could be live or stage" |
|||
echo |
|||
echo "--help Prints this message" |
|||
echo |
|||
} |
|||
|
|||
source "$project_manager_dir/bin/includes/project_header" |
|||
env="$(getArgument "$2" "$(usage)" "live stage")" |
|||
pleskValidate "$env" |
|||
|
|||
db_user="$(dbGetConfig "$env" "user")" |
|||
db_password="$(dbGetConfig "$env" "password")" |
|||
db_database="$(dbGetConfig "$env" "database")" |
|||
domain="$(getConfig "$env" "domain")" |
|||
|
|||
split=($(echo $domain | tr "." "\n")) |
|||
count="${#split[@]}" |
|||
((length=$count-2)) |
|||
sub='' |
|||
for i in "${!split[@]}" |
|||
do |
|||
((j=$i+1)) |
|||
if [ "$j" -lt "$length" ] |
|||
then |
|||
sub+="${split[$i]}." |
|||
fi |
|||
if [ "$j" -eq "$length" ] |
|||
then |
|||
sub+="${split[$i]}" |
|||
fi |
|||
done |
|||
domain="$(echo "$domain" | sed "s/$(sedEscape "$sub")\.//")" |
|||
|
|||
echo |
|||
echoMainTitle "Adding database on plesk server" |
|||
echo |
|||
echoSubTitle "Please verify data" |
|||
echo |
|||
echo "-- $env" |
|||
echo "Domain: $domain" |
|||
echo |
|||
echo "Database name: $db_database" |
|||
echo "Database user: $db_user" |
|||
echo |
|||
echo "Plesk host: $plesk_host" |
|||
echo "Plesk user: $plesk_user" |
|||
echo "Plesk private key: $plesk_private_key" |
|||
echo "Plesk public key: $plesk_public_key" |
|||
echo |
|||
confirm |
|||
|
|||
pleskAddSSHKey |
|||
|
|||
ssh "$plesk_user@$plesk_host" "plesk bin database --create '$db_database' -domain '$domain' -type '$plesk_db_type' -server 'localhost'" |
|||
ssh "$plesk_user@$plesk_host" "plesk bin database --create-dbuser '$db_user' -passwd '$db_password' -domain '$domain' -database '$db_database' -server 'localhost'" |
|||
|
|||
echo |
|||
echoSuccess "Database has been created on plesk" |
|||
echo |
@ -0,0 +1,62 @@ |
|||
#!/bin/bash |
|||
|
|||
function usage { |
|||
echo |
|||
echoMainTitle "Creates a subdomain on plesk server" |
|||
echo |
|||
echoSubTitle "Usage:" |
|||
echo |
|||
echo "project-manager plesk:create-subdomain [project-shortname] [env]" |
|||
echo |
|||
echo " [env] could be live or stage" |
|||
echo |
|||
echo "--help Prints this message" |
|||
echo |
|||
} |
|||
|
|||
source "$project_manager_dir/bin/includes/project_header" |
|||
env="$(getArgument "$2" "$(usage)" "live stage")" |
|||
pleskValidate "$env" |
|||
|
|||
domain="$(getConfig "$env" "domain")" |
|||
split=($(echo $domain | tr "." "\n")) |
|||
count="${#split[@]}" |
|||
((length=$count-2)) |
|||
sub='' |
|||
for i in "${!split[@]}" |
|||
do |
|||
((j=$i+1)) |
|||
if [ "$j" -lt "$length" ] |
|||
then |
|||
sub+="${split[$i]}." |
|||
fi |
|||
if [ "$j" -eq "$length" ] |
|||
then |
|||
sub+="${split[$i]}" |
|||
fi |
|||
done |
|||
domain="$(echo "$domain" | sed "s/$(sedEscape "$sub")\.//")" |
|||
|
|||
echo |
|||
echoMainTitle "Adding subdomain on plesk server" |
|||
echo |
|||
echoSubTitle "Please verify data" |
|||
echo |
|||
echo "-- $env" |
|||
echo "Domain: $domain" |
|||
echo "Sub: $sub" |
|||
echo |
|||
echo "Plesk host: $plesk_host" |
|||
echo "Plesk user: $plesk_user" |
|||
echo "Plesk private key: $plesk_private_key" |
|||
echo "Plesk public key: $plesk_public_key" |
|||
echo |
|||
confirm |
|||
|
|||
pleskAddSSHKey |
|||
|
|||
ssh "$plesk_user@$plesk_host" "plesk bin subdomain --create '$sub' -domain '$domain' -www-root '/$sub.$domain'" |
|||
|
|||
echo |
|||
echoSuccess "Subdomain has been created on plesk" |
|||
echo |
@ -0,0 +1,10 @@ |
|||
#!/bin/bash |
|||
|
|||
plesk_host='' |
|||
plesk_user='' |
|||
plesk_private_key='' |
|||
plesk_public_key='' |
|||
|
|||
plesk_db_type='mysql' |
|||
|
|||
plesk_binary='plesk' |
@ -0,0 +1,59 @@ |
|||
#!/bin/bash |
|||
|
|||
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" |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue