|
@ -25,9 +25,8 @@ then |
|
|
local project="$(getConfig false "project_manager.projects.$escapedShortname.project")" |
|
|
local project="$(getConfig false "project_manager.projects.$escapedShortname.project")" |
|
|
local tempDir="$project_manager_dir/var/tmp/$customer/$project/ssh-keys" |
|
|
local tempDir="$project_manager_dir/var/tmp/$customer/$project/ssh-keys" |
|
|
local sshDir="$project_manager_dir/data/$customer/$project/.ssh" |
|
|
local sshDir="$project_manager_dir/data/$customer/$project/.ssh" |
|
|
local date="$(date 'Y.m.d_H:i:s')" |
|
|
|
|
|
local rand="$shortname-$(cat /proc/sys/kernel/random/uuid)" |
|
|
local rand="$shortname-$(cat /proc/sys/kernel/random/uuid)" |
|
|
local backupDir="$project_manager_dir/.trash/$customer/$project/$rand/.ssh" |
|
|
|
|
|
|
|
|
local backupDir="$project_manager_dir/.trash/$rand/.ssh" |
|
|
|
|
|
|
|
|
if [ ! -d "$sshDir" ]; then mkdir -p "$sshDir"; fi |
|
|
if [ ! -d "$sshDir" ]; then mkdir -p "$sshDir"; fi |
|
|
if [ -f "$sshDir/$name" ] || [ -f "$sshDir/$name.pub" ]; then mkdir -p "$backupDir"; fi |
|
|
if [ -f "$sshDir/$name" ] || [ -f "$sshDir/$name.pub" ]; then mkdir -p "$backupDir"; fi |
|
@ -44,19 +43,30 @@ then |
|
|
local name="$(getArgument "$2" "name required" true)" |
|
|
local name="$(getArgument "$2" "name required" true)" |
|
|
local privateKeyFile="$(getArgument "$3" "private key file required" true)" |
|
|
local privateKeyFile="$(getArgument "$3" "private key file required" true)" |
|
|
local publicKeyFile="$(getArgument "$4" "public key file required" true)" |
|
|
local publicKeyFile="$(getArgument "$4" "public key file required" true)" |
|
|
|
|
|
local escapedShortname=${shortname//./\\.} |
|
|
local customer="$(getConfig false "project_manager.projects.$escapedShortname.customer")" |
|
|
local customer="$(getConfig false "project_manager.projects.$escapedShortname.customer")" |
|
|
local project="$(getConfig false "project_manager.projects.$escapedShortname.project")" |
|
|
local project="$(getConfig false "project_manager.projects.$escapedShortname.project")" |
|
|
local sshDir="$project_manager_dir/data/$customer/$project/.ssh" |
|
|
local sshDir="$project_manager_dir/data/$customer/$project/.ssh" |
|
|
|
|
|
local rand="$shortname-$(cat /proc/sys/kernel/random/uuid)" |
|
|
|
|
|
local trash="$project_manager_dir/.trash/$rand/.ssh" |
|
|
|
|
|
local getPrivateKey="$(if [ -n "$(cmp "$sshDir/$name" "$privateKeyFile")" ]; then echo true; else echo false; fi;)" |
|
|
|
|
|
local getPublicKey="$(if [ -n "$(cmp "$sshDir/$name.pub" "$publicKeyFile")" ]; then echo true; else echo false; fi;)" |
|
|
|
|
|
|
|
|
if [ ! -d "$sshDir" ]; then mkdir -p "$sshDir"; fi |
|
|
if [ ! -d "$sshDir" ]; then mkdir -p "$sshDir"; fi |
|
|
if [ -f "$sshDir/$name" ] || [ -f "$sshDir/$name.pub" ]; then mkdir -p "$backupDir"; fi |
|
|
|
|
|
if [ -f "$sshDir/$name" ]; then mv "$sshDir/$name" "$backupDir/$name" && chmod 0600 "$backupDir/$name"; fi |
|
|
|
|
|
if [ -f "$sshDir/$name.pub" ]; then mv "$sshDir/$name" "$backupDir/$name.pub" && chmod 0600 "$backupDir/$name.pub"; fi |
|
|
|
|
|
|
|
|
if [ -f "$sshDir/$name" ] && [ true == $getPrivateKey ]; then mkdir -p "$trash"; mv "$sshDir/$name" "$trash/$name" && chmod 0600 "$trash/$name"; fi |
|
|
|
|
|
if [ -f "$sshDir/$name.pub" ] && [ true == $getPublicKey ]; then mkdir -p "$trash"; mv "$sshDir/$name.pub" "$trash/$name.pub" && chmod 0600 "$trash/$name.pub"; fi |
|
|
|
|
|
|
|
|
|
|
|
if [ true == $getPrivateKey ] |
|
|
|
|
|
then |
|
|
cp "$privateKeyFile" "$sshDir/$name" |
|
|
cp "$privateKeyFile" "$sshDir/$name" |
|
|
chmod 0600 "$sshDir/$name" |
|
|
chmod 0600 "$sshDir/$name" |
|
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
|
|
if [ true == $getPublicKey ] |
|
|
|
|
|
then |
|
|
cp "$publicKeyFile" "$sshDir/$name.pub" |
|
|
cp "$publicKeyFile" "$sshDir/$name.pub" |
|
|
chmod 0600 "$sshDir/$name.pub" |
|
|
chmod 0600 "$sshDir/$name.pub" |
|
|
|
|
|
fi |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function sshInstallRemoteKey { |
|
|
function sshInstallRemoteKey { |
|
@ -64,7 +74,8 @@ then |
|
|
local name="$(getArgument "$2" "name required" true)" |
|
|
local name="$(getArgument "$2" "name required" true)" |
|
|
local user="$(getArgument "$3" "user required" true)" |
|
|
local user="$(getArgument "$3" "user required" true)" |
|
|
local host="$(getArgument "$4" "host required" true)" |
|
|
local host="$(getArgument "$4" "host required" true)" |
|
|
local port="${$(getArgument "$2"):-22}" |
|
|
|
|
|
|
|
|
local port="${5:-"22"}" |
|
|
|
|
|
local escapedShortname=${shortname//./\\.} |
|
|
local customer="$(getConfig false "project_manager.projects.$escapedShortname.customer")" |
|
|
local customer="$(getConfig false "project_manager.projects.$escapedShortname.customer")" |
|
|
local project="$(getConfig false "project_manager.projects.$escapedShortname.project")" |
|
|
local project="$(getConfig false "project_manager.projects.$escapedShortname.project")" |
|
|
local sshDir="$project_manager_dir/data/$customer/$project/.ssh" |
|
|
local sshDir="$project_manager_dir/data/$customer/$project/.ssh" |
|
|