From e0839547daf3e888df9cecbcf02bb65e862bba8a Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 25 Mar 2024 08:18:45 +0100 Subject: [PATCH 1/7] .sh --- cd => cd.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename cd => cd.sh (100%) diff --git a/cd b/cd.sh similarity index 100% rename from cd rename to cd.sh From 003deb6455edfcc3d19640422f9ad474ce3e2041 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 25 Mar 2024 09:02:43 +0100 Subject: [PATCH 2/7] split --- cd-bootstrap => cd-bootstrap.sh | 0 cd.sh | 20 +++++++++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) rename cd-bootstrap => cd-bootstrap.sh (100%) diff --git a/cd-bootstrap b/cd-bootstrap.sh similarity index 100% rename from cd-bootstrap rename to cd-bootstrap.sh diff --git a/cd.sh b/cd.sh index 2db24e9..020f5fe 100644 --- a/cd.sh +++ b/cd.sh @@ -1,5 +1,15 @@ -echo 'nameserver 9.9.9.9' > '/etc/resolv.conf' \ -&& apt-get update \ -&& apt-get install --yes 'git' \ -&& git clone "${GITHUB_SERVER_URL}/rwx.work/cd" '/usr/local/sbin' \ -&& cd-bootstrap +echo "\ +nameserver 9.9.9.9 +" > '/etc/resolv.conf' \ +&& \ +apt-get update \ +&& \ +apt-get install \ +'git' \ +--yes \ +&& \ +git clone \ +"${GITHUB_SERVER_URL}/rwx.work/cd" \ +'/usr/local/sbin' \ +&& \ +cd-bootstrap.sh From 358fd7d6874aca412edd23b1ca4b85ba3082bcdf Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 25 Mar 2024 12:26:38 +0100 Subject: [PATCH 3/7] vars --- cd.sh | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/cd.sh b/cd.sh index 020f5fe..583d97d 100644 --- a/cd.sh +++ b/cd.sh @@ -1,15 +1,27 @@ -echo "\ -nameserver 9.9.9.9 -" > '/etc/resolv.conf' \ -&& \ +NAMESERVERS=( +'9.9.9.9' +) +PACKAGES=( +'git' +) +REPOSITORY='rwx.work/cd' +TARGET='/usr/local/sbin' + +for nameserver in "${NAMESERVERS[@]}" ; do + echo "nameserver ${nameserver}" \ + >> '/etc/resolv.conf' \ + || exit +done + apt-get update \ -&& \ -apt-get install \ -'git' \ ---yes \ -&& \ +|| exit + +apt-get install --yes "${PACKAGES[@]}" \ +|| exit + git clone \ -"${GITHUB_SERVER_URL}/rwx.work/cd" \ -'/usr/local/sbin' \ -&& \ +"${GITHUB_SERVER_URL}/${REPOSITORY}" \ +"${TARGET}" \ +|| exit + cd-bootstrap.sh From 6cde24300528b5b2f8163ff177d8bea505a51fda Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 25 Mar 2024 12:53:37 +0100 Subject: [PATCH 4/7] clear known_hosts --- cd-bootstrap.sh | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/cd-bootstrap.sh b/cd-bootstrap.sh index 85c1259..a6045ad 100755 --- a/cd-bootstrap.sh +++ b/cd-bootstrap.sh @@ -1,20 +1,28 @@ +KEY_ALGORITHM='ed25519' +KEY_PATH=".ssh/id_ed25519" +KEY_PUBLIC='AAAAC3NzaC1lZDI1NTE5AAAAIPHCNcgHlQoiNTXfnUZYvHz9OZwYsmBCrSSV7a7Zche5' +PACKAGES=( +'python3' +'rsync' +'tree' +) +SERVER="$(basename ${GITHUB_SERVER_URL})" + # ssh -mkdir --parents ~/.ssh +mkdir '.ssh' \ +|| exit -echo "${CD}" > ~/.ssh/id_ed25519 +echo "${CD}" > "${KEY_PATH}" \ +|| exit unset CD -chmod 400 ~/.ssh/id_ed25519 +chmod '400' "${KEY_PATH}" \ +|| exit -echo -n "\ -|1|BcccCTMLpM9HHSgJmPu/FFOwOv0=|+3BKK02xibpCPxQ9Nghi2GbXLng= \ -ssh-ed25519 \ -AAAAC3NzaC1lZDI1NTE5AAAAIPHCNcgHlQoiNTXfnUZYvHz9OZwYsmBCrSSV7a7Zche5 -" > ~/.ssh/known_hosts +echo "${SERVER} ssh-${KEY_ALGORITHM} ${KEY_PUBLIC}" \ +> '.ssh/known_hosts' \ +|| exit # packages -apt-get install --yes \ -'python3' \ -'rsync' \ -'tree' \ +apt-get install --yes "${PACKAGES[@]}" From e40ae2dba2d70796d4692c776b35c83b899dd6e3 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 25 Mar 2024 15:36:24 +0100 Subject: [PATCH 5/7] tmp/fix --- cd-bootstrap.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cd-bootstrap.sh b/cd-bootstrap.sh index a6045ad..5a92d51 100755 --- a/cd-bootstrap.sh +++ b/cd-bootstrap.sh @@ -19,7 +19,8 @@ unset CD chmod '400' "${KEY_PATH}" \ || exit -echo "${SERVER} ssh-${KEY_ALGORITHM} ${KEY_PUBLIC}" \ +echo "|1|BcccCTMLpM9HHSgJmPu/FFOwOv0=|+3BKK02xibpCPxQ9Nghi2GbXLng= \ +ssh-${KEY_ALGORITHM} ${KEY_PUBLIC}" \ > '.ssh/known_hosts' \ || exit From 0b55a80d9796c3091f95630ba336b5117afcf59a Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 25 Mar 2024 15:42:26 +0100 Subject: [PATCH 6/7] cd --- cd-bootstrap.sh | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/cd-bootstrap.sh b/cd-bootstrap.sh index 5a92d51..3fc156a 100755 --- a/cd-bootstrap.sh +++ b/cd-bootstrap.sh @@ -1,5 +1,5 @@ KEY_ALGORITHM='ed25519' -KEY_PATH=".ssh/id_ed25519" +KEY_PATH=".ssh/id_${KEY_ALGORITHM}" KEY_PUBLIC='AAAAC3NzaC1lZDI1NTE5AAAAIPHCNcgHlQoiNTXfnUZYvHz9OZwYsmBCrSSV7a7Zche5' PACKAGES=( 'python3' @@ -9,21 +9,17 @@ PACKAGES=( SERVER="$(basename ${GITHUB_SERVER_URL})" # ssh - +cd mkdir '.ssh' \ || exit - echo "${CD}" > "${KEY_PATH}" \ || exit unset CD chmod '400' "${KEY_PATH}" \ || exit - -echo "|1|BcccCTMLpM9HHSgJmPu/FFOwOv0=|+3BKK02xibpCPxQ9Nghi2GbXLng= \ -ssh-${KEY_ALGORITHM} ${KEY_PUBLIC}" \ +echo "${SERVER} ssh-${KEY_ALGORITHM} ${KEY_PUBLIC}" \ > '.ssh/known_hosts' \ || exit # packages - apt-get install --yes "${PACKAGES[@]}" From a21a21be9a2155cdf565febb5df2a82f5211c62e Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 25 Mar 2024 15:47:24 +0100 Subject: [PATCH 7/7] keydir --- cd-bootstrap.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/cd-bootstrap.sh b/cd-bootstrap.sh index 3fc156a..dbab7b6 100755 --- a/cd-bootstrap.sh +++ b/cd-bootstrap.sh @@ -1,5 +1,6 @@ KEY_ALGORITHM='ed25519' -KEY_PATH=".ssh/id_${KEY_ALGORITHM}" +KEY_DIRECTORY='.ssh' +KEY_PATH="${KEY_DIRECTORY}/id_${KEY_ALGORITHM}" KEY_PUBLIC='AAAAC3NzaC1lZDI1NTE5AAAAIPHCNcgHlQoiNTXfnUZYvHz9OZwYsmBCrSSV7a7Zche5' PACKAGES=( 'python3' @@ -9,8 +10,9 @@ PACKAGES=( SERVER="$(basename ${GITHUB_SERVER_URL})" # ssh -cd -mkdir '.ssh' \ +cd \ +|| exit +mkdir "${KEY_DIRECTORY}" \ || exit echo "${CD}" > "${KEY_PATH}" \ || exit @@ -18,7 +20,7 @@ unset CD chmod '400' "${KEY_PATH}" \ || exit echo "${SERVER} ssh-${KEY_ALGORITHM} ${KEY_PUBLIC}" \ -> '.ssh/known_hosts' \ +> "${KEY_DIRECTORY}/known_hosts" \ || exit # packages