Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 08e9ff9e67 | |||
| 329f3abb6b | |||
| 495879207c | |||
| 6048c11791 |
@@ -37,9 +37,12 @@ Planned to get auto fixes for wrong ACL, etc or missing config settings
|
|||||||
A SSH Key has to be generated for each git respository that will be synced and the configuration has to be added to the ssh config file
|
A SSH Key has to be generated for each git respository that will be synced and the configuration has to be added to the ssh config file
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
create_ssh_config.sh [SSH Key name] [repo url full] ([jump proxy])
|
create_ssh_config.sh [repo url full] ([jump proxy])
|
||||||
```
|
```
|
||||||
|
|
||||||
|
> [!notice]
|
||||||
|
> This will currently output the command to create the SSH key and the host config to add to the ssh config file
|
||||||
|
|
||||||
### new_clone.sh
|
### new_clone.sh
|
||||||
|
|
||||||
Create a new clone
|
Create a new clone
|
||||||
|
|||||||
@@ -13,6 +13,10 @@
|
|||||||
|
|
||||||
REPOSITORY="$1";
|
REPOSITORY="$1";
|
||||||
JUMP_PROXY="$2";
|
JUMP_PROXY="$2";
|
||||||
|
if [ "${REPOSITORY}" == "--help" ]; then
|
||||||
|
echo "$0 <Repo.git> [<Jump Proxy>]";
|
||||||
|
exit;
|
||||||
|
fi;
|
||||||
# below are only to skip error
|
# below are only to skip error
|
||||||
BRANCH="-"
|
BRANCH="-"
|
||||||
|
|
||||||
@@ -28,7 +32,9 @@ if [ ! -f "${SSH_CONFIG_BASE}config" ]; then
|
|||||||
fi;
|
fi;
|
||||||
|
|
||||||
if [[ "${REPOSITORY}" == *":"* ]]; then
|
if [[ "${REPOSITORY}" == *":"* ]]; then
|
||||||
REMOTE_HOST=$(echo "${REPOSITORY}" | cut -d ":" -f 1);
|
REMOTE_USER_HOST=$(echo "${REPOSITORY}" | cut -d ":" -f 1);
|
||||||
|
REMOTE_HOST=$(echo "${REMOTE_USER_HOST}" | cut -d "@" -f 2);
|
||||||
|
REMOTE_USER=$(echo "${REMOTE_USER_HOST}" | cut -d "@" -f 1);
|
||||||
else
|
else
|
||||||
echo "[!] Must set a full repository path with remote host for the repository";
|
echo "[!] Must set a full repository path with remote host for the repository";
|
||||||
error=1;
|
error=1;
|
||||||
@@ -59,7 +65,8 @@ fi;
|
|||||||
# SUDO_COMMAND= as base
|
# SUDO_COMMAND= as base
|
||||||
# ssh-keygen -t ed25519 -N "" -C "${GIT_REPOSITORY_NAME}" -f "${SSH_CONFIG_BASE}${SSH_KEY_NAME}"
|
# ssh-keygen -t ed25519 -N "" -C "${GIT_REPOSITORY_NAME}" -f "${SSH_CONFIG_BASE}${SSH_KEY_NAME}"
|
||||||
# must add ".pem" if key name does not end in .pem
|
# must add ".pem" if key name does not end in .pem
|
||||||
SSH_COMMAND=("${SUDO_COMMAND[@]}" "ssh-keygen" "-t" "ed25519" "-N" "" "-C" "${GIT_REPOSITORY_NAME}" "-f" "${SSH_CONFIG_BASE}${GIT_REPOSITORY_NAME}.pem")
|
SSH_COMMAND=("${SUDO_COMMAND[@]}" "ssh-keygen" "-t" "ed25519" "-N" "\"\"" "-C" "${GIT_REPOSITORY_NAME}" "-f" "${SSH_CONFIG_BASE}${GIT_REPOSITORY_NAME}.pem")
|
||||||
|
SSH_CONFIG_COMMAND=("${SUDO_COMMAND[@]}" "vim" "${SSH_CONFIG_BASE}config")
|
||||||
|
|
||||||
# debug output for now
|
# debug output for now
|
||||||
echo "";
|
echo "";
|
||||||
@@ -69,9 +76,11 @@ echo "${SSH_COMMAND[*]}";
|
|||||||
echo "";
|
echo "";
|
||||||
echo "* ADD TO: ${SSH_CONFIG_BASE}config";
|
echo "* ADD TO: ${SSH_CONFIG_BASE}config";
|
||||||
echo "";
|
echo "";
|
||||||
echo "Host ${GIT_REPOSITORY_NAME}":
|
echo "${SSH_CONFIG_COMMAND[*]}";
|
||||||
|
echo "";
|
||||||
|
echo "Host ${GIT_REPOSITORY_NAME}"
|
||||||
echo " Hostname ${REMOTE_HOST}";
|
echo " Hostname ${REMOTE_HOST}";
|
||||||
echo " User git";
|
echo " User ${REMOTE_USER}";
|
||||||
echo " PreferredAuthentications publickey";
|
echo " PreferredAuthentications publickey";
|
||||||
echo " IdentityFile ~/.ssh/${GIT_REPOSITORY_NAME}.pem";
|
echo " IdentityFile ~/.ssh/${GIT_REPOSITORY_NAME}.pem";
|
||||||
if [ -n "${JUMP_PROXY}" ]; then
|
if [ -n "${JUMP_PROXY}" ]; then
|
||||||
|
|||||||
@@ -7,6 +7,10 @@
|
|||||||
REPOSITORY="$1";
|
REPOSITORY="$1";
|
||||||
BRANCH="$2";
|
BRANCH="$2";
|
||||||
REMOTE_NAME="$3";
|
REMOTE_NAME="$3";
|
||||||
|
if [ "${REPOSITORY}" == "--help" ]; then
|
||||||
|
echo "$0 <Repo.git> <branch> [<remote name, defaults to origin>]";
|
||||||
|
exit;
|
||||||
|
fi;
|
||||||
if [ -z "${REMOTE_NAME}" ]; then
|
if [ -z "${REMOTE_NAME}" ]; then
|
||||||
REMOTE_NAME="origin"
|
REMOTE_NAME="origin"
|
||||||
fi;
|
fi;
|
||||||
|
|||||||
@@ -11,6 +11,10 @@ BRANCH="$2";
|
|||||||
REMOTE_HOST="$3";
|
REMOTE_HOST="$3";
|
||||||
REPOSITORY_FOLDER="$4"
|
REPOSITORY_FOLDER="$4"
|
||||||
REMOTE_NAME="$5";
|
REMOTE_NAME="$5";
|
||||||
|
if [ "${REPOSITORY}" == "--help" ]; then
|
||||||
|
echo "$0 <Repo.git> <branch> [<override host>] [<target folder>] [<remote name, defaults to origin>]";
|
||||||
|
exit;
|
||||||
|
fi;
|
||||||
if [ -z "${REMOTE_NAME}" ]; then
|
if [ -z "${REMOTE_NAME}" ]; then
|
||||||
REMOTE_NAME="origin"
|
REMOTE_NAME="origin"
|
||||||
fi;
|
fi;
|
||||||
@@ -22,15 +26,6 @@ if [ -z "${REPOSITORY}" ]; then
|
|||||||
echo "[!] Must set a repository path";
|
echo "[!] Must set a repository path";
|
||||||
error=1;
|
error=1;
|
||||||
fi;
|
fi;
|
||||||
# if remote host is empty try to set from repository
|
|
||||||
if [ -z "${REMOTE_HOST}" ]; then
|
|
||||||
if [[ "${REPOSITORY}" == *":"* ]]; then
|
|
||||||
REMOTE_HOST=$(echo "${REPOSITORY}" | cut -d ":" -f 1);
|
|
||||||
else
|
|
||||||
echo "[!] Must set a repository path with remote host for the repository";
|
|
||||||
error=1;
|
|
||||||
fi;
|
|
||||||
fi;
|
|
||||||
# if we have an ":" in the repository, split by it and replace it with the remote host
|
# if we have an ":" in the repository, split by it and replace it with the remote host
|
||||||
if [[ "${REPOSITORY}" == *":"* ]]; then
|
if [[ "${REPOSITORY}" == *":"* ]]; then
|
||||||
REPOSITORY=$(echo "${REPOSITORY}" | cut -d ":" -f 2);
|
REPOSITORY=$(echo "${REPOSITORY}" | cut -d ":" -f 2);
|
||||||
@@ -41,14 +36,18 @@ if [ -z "${REPOSITORY_FOLDER}" ]; then
|
|||||||
else
|
else
|
||||||
GIT_REPOSITORY_NAME="${REPOSITORY_FOLDER}";
|
GIT_REPOSITORY_NAME="${REPOSITORY_FOLDER}";
|
||||||
fi;
|
fi;
|
||||||
|
# set remote host if not set to the ssh config name
|
||||||
|
if [ -z "${REMOTE_HOST}" ]; then
|
||||||
|
REMOTE_HOST="${GIT_REPOSITORY_NAME}";
|
||||||
|
fi;
|
||||||
if [ $error -eq 1 ]; then
|
if [ $error -eq 1 ]; then
|
||||||
exit;
|
exit;
|
||||||
fi;
|
fi;
|
||||||
|
|
||||||
error=0
|
error=0
|
||||||
echo "* Validate SSH PEM Key exist and SSH config";
|
echo "* Validate SSH PEM Key exist and SSH config";
|
||||||
if ! grep "Host ${GIT_REPOSITORY_NAME}" "${GIT_WEBHOOK_BASE_FOLDER}"/.ssh/config; then
|
if ! grep "Host ${REMOTE_HOST}" "${GIT_WEBHOOK_BASE_FOLDER}"/.ssh/config; then
|
||||||
echo "[!] ssh config entry for Host ${GIT_REPOSITORY_NAME} is missing";
|
echo "[!] ssh config entry for Host ${REMOTE_HOST} is missing";
|
||||||
error=1;
|
error=1;
|
||||||
else
|
else
|
||||||
# make sure the identiy file is there
|
# make sure the identiy file is there
|
||||||
|
|||||||
@@ -8,6 +8,10 @@
|
|||||||
REPOSITORY="$1";
|
REPOSITORY="$1";
|
||||||
BRANCH="$2";
|
BRANCH="$2";
|
||||||
REMOTE_NAME="$3";
|
REMOTE_NAME="$3";
|
||||||
|
if [ "${REPOSITORY}" == "--help" ]; then
|
||||||
|
echo "$0 <Repo.git> <branch> [<remote name, defaults to origin>]";
|
||||||
|
exit;
|
||||||
|
fi;
|
||||||
if [ -z "${REMOTE_NAME}" ]; then
|
if [ -z "${REMOTE_NAME}" ]; then
|
||||||
REMOTE_NAME="origin"
|
REMOTE_NAME="origin"
|
||||||
fi;
|
fi;
|
||||||
|
|||||||
Reference in New Issue
Block a user