mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-11-04 01:59:35 +00:00
b5938: Reverse symlink directions for files in configuration
This commit is contained in:
1 parent
9c57db5a2f
commit
b5e8ccdf81
8 files changed
+127
-127
No files matched your search
@@ -1 +0,0 @@
|
||||
../../../../../syncgit
|
||||
@@ -0,0 +1,16 @@
|
||||
#!/bin/sh
|
||||
ADMIN_EMAIL="axel.uhl@sap.com jan.hamann@sapsailing.com"
|
||||
if [ $# -eq 0 ]; then
|
||||
GIT_PATH="/home/wiki/gitwiki"
|
||||
else
|
||||
GIT_PATH=$1
|
||||
fi
|
||||
cd $GIT_PATH
|
||||
git pull >/tmp/wiki-git.out 2>/tmp/wiki-git.err
|
||||
if [ "$?" != "0" ]; then
|
||||
cat /tmp/wiki-git.out /tmp/wiki-git.err | mail -s "Wiki git problem" $ADMIN_EMAIL
|
||||
fi
|
||||
git push >>/tmp/wiki-git.out 2>/tmp/wiki-git.err
|
||||
if [ "$?" != "0" ]; then
|
||||
cat /tmp/wiki-git.out /tmp/wiki-git.err | mail -s "Wiki git problem" $ADMIN_EMAIL
|
||||
fi
|
||||
-1
@@ -1 +0,0 @@
|
||||
../../../../../update_authorized_keys_for_landscape_managers
|
||||
Executable
+48
@@ -0,0 +1,48 @@
|
||||
#!/bin/bash
|
||||
BEARER_TOKEN="$1"
|
||||
BASE_URL="$2"
|
||||
LOGON_USER_HOME="$3"
|
||||
SSH_DIR="$3/.ssh"
|
||||
EXIT_CODE=0
|
||||
#
|
||||
curl_output=$( curl -H 'X-SAPSSE-Forward-Request-To: master' -H 'Authorization: Bearer '${BEARER_TOKEN} "${BASE_URL}/security/api/restsecurity/users_with_permission?permission=LANDSCAPE:MANAGE:AWS" 2>/dev/null )
|
||||
curl_exit_code=$?
|
||||
if [ "${curl_exit_code}" = "0" ]; then
|
||||
users=$( echo "${curl_output}" | jq -r '.[]' )
|
||||
jq_exit_code=$?
|
||||
if [ "${jq_exit_code}" = "0" ]; then
|
||||
logger -t sailing "Users with LANDSCAPE:MANAGE:AWS permission: ${users}"
|
||||
public_keys=$( for user in ${users}; do
|
||||
ssh_key_curl_output=$(curl -H 'X-SAPSSE-Forward-Request-To: master' -H 'Authorization: Bearer '${BEARER_TOKEN} "${BASE_URL}/landscape/api/landscape/get_ssh_keys_owned_by_user?username[]=${user}" 2>/dev/null )
|
||||
ssh_key_curl_exit_code=$?
|
||||
if [ "${ssh_key_curl_exit_code}" = "0" ]; then
|
||||
echo "${ssh_key_curl_output}" | jq -r '.[].publicKey'
|
||||
ssh_key_jq_exit_code=$?
|
||||
if [ "${ssh_key_jq_exit_code}" != "0" ]; then
|
||||
EXIT_CODE=${ssh_key_jq_exit_code}
|
||||
logger -t sailing "Couldn't parse response of get_ssh_keys_owned_by_user; jq exit code ${ssh_key_jq_exit_code}"
|
||||
fi
|
||||
else
|
||||
EXIT_CODE=${ssh_key_curl_exit_code}
|
||||
logger -t sailing "Couldn't get response of get_ssh_keys_owned_by_user; curl exit code ${ssh_key_corl_exit_code}"
|
||||
fi
|
||||
done | sort -u )
|
||||
logger -t sailing "Obtained public keys: ${public_keys}"
|
||||
if [ ! -f ${SSH_DIR}/authorized_keys.org ]; then
|
||||
# Create a copy of the original authorized_keys file as generated by AWS from the start-up key:
|
||||
logger -t sailing "Saving original authorized_keys file from ${SSH_DIR}"
|
||||
cp ${SSH_DIR}/authorized_keys ${SSH_DIR}/authorized_keys.org
|
||||
fi
|
||||
# Start out with the original AWS-generated authorized_keys file
|
||||
# and append the public SSH keys of all users having LANDSCAPE:MANAGE:AWS permission:
|
||||
echo "$( cat ${SSH_DIR}/authorized_keys.org )
|
||||
${public_keys}" | sort -u >${SSH_DIR}/authorized_keys
|
||||
else
|
||||
EXIT_CODE=${jq_exit_code}
|
||||
logger -t sailing "Couldn't parse response of users_with_permission; jq exit code ${jq_exit_code}"
|
||||
fi
|
||||
else
|
||||
EXIT_CODE=${curl_exit_code}
|
||||
logger -t sailing "Couldn't get response of users_with_permission; curl exit code ${curl_exit_code}"
|
||||
fi
|
||||
exit ${EXIT_CODE}
|
||||
-1
@@ -1 +0,0 @@
|
||||
../../../../../update_authorized_keys_for_landscape_managers_if_changed
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
#!/bin/bash
|
||||
BEARER_TOKEN="$1"
|
||||
BASE_URL="$2"
|
||||
LOGON_USER_HOME="$3"
|
||||
LAST_CHANGE_FILE=/var/run/last_change_aws_landscape_managers_ssh_keys
|
||||
# Uncomment the following for production use, with no error output
|
||||
curl_output=$( curl -H 'X-SAPSSE-Forward-Request-To: master' -H 'Authorization: Bearer '${BEARER_TOKEN} "${BASE_URL}/landscape/api/landscape/get_time_point_of_last_change_in_ssh_keys_of_aws_landscape_managers" 2>/dev/null )
|
||||
curl_exit_code=$?
|
||||
if [ "${curl_exit_code}" = "0" ]; then
|
||||
last_change_millis=$( echo "${curl_output}" | jq -r '."timePointOfLastChangeOfSetOfLandscapeManagers-millis"' )
|
||||
jq_exit_code=$?
|
||||
if [ "${jq_exit_code}" = "0" ]; then
|
||||
if [ -f "${LAST_CHANGE_FILE}" ]; then
|
||||
PREVIOUS_CHANGE=$(cat "${LAST_CHANGE_FILE}")
|
||||
if [ -z ${PREVIOUS_CHANGE} ]; then
|
||||
PREVIOUS_CHANGE=0
|
||||
fi
|
||||
else
|
||||
PREVIOUS_CHANGE=0
|
||||
fi
|
||||
if [ -z ${last_change_millis} ]; then
|
||||
logger -t sailing "Empty response from get_time_point_of_last_change_in_ssh_keys_of_aws_landscape_managers; exiting"
|
||||
exit 1
|
||||
else
|
||||
if [ ${PREVIOUS_CHANGE} -lt ${last_change_millis} ]; then
|
||||
logger -t sailing "New SSH key changes for landscape managers (${last_change_millis} newer than ${PREVIOUS_CHANGE})"
|
||||
if update_authorized_keys_for_landscape_managers "${BEARER_TOKEN}" "${BASE_URL}" "${LOGON_USER_HOME}" ; then
|
||||
logger -t sailing "Updating SSH keys for landscape managers successful; updating ${LAST_CHANGE_FILE}"
|
||||
echo ${last_change_millis} >${LAST_CHANGE_FILE}
|
||||
else
|
||||
logger -t sailing "Updating SSH keys for landscape managers failed with exit code $?; not updating ${LAST_CHANGE_FILE}"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
else
|
||||
logger -t sailing "Parsing response of get_time_point_of_last_change_in_ssh_keys_of_aws_landscape_managers failed with exit code ${jq_exit_code}"
|
||||
exit ${jq_exit_code}
|
||||
fi
|
||||
else
|
||||
logger -t sailing "Getting response of get_time_point_of_last_change_in_ssh_keys_of_aws_landscape_managers failed with exit code ${curl_exit_code}"
|
||||
exit ${curl_exit_code}
|
||||
fi
|
||||
-1
@@ -1 +0,0 @@
|
||||
../../../../../update_landscape_managers_mailing_list.sh
|
||||
Executable
+17
@@ -0,0 +1,17 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Purpose: Create a mailing list in PATH_TO_STORE/landscapeManagersMailingList that contains the emails of all landscape managers, ie. those who
|
||||
# have complete admin privileges in the aws environment.
|
||||
BEARER_TOKEN="$1"
|
||||
PATH_TO_STORE="$2"
|
||||
NAME_TO_STORE_IN="landscapeManagersMailingList"
|
||||
BASE_URL="https://security-service.sapsailing.com"
|
||||
curl_output=$( curl -H 'X-SAPSSE-Forward-Request-To: master' -H 'Authorization: Bearer '${BEARER_TOKEN} "${BASE_URL}/security/api/restsecurity/users_with_permission?permission=LANDSCAPE:MANAGE:AWS" 2>/dev/null )
|
||||
if [[ -f "${PATH_TO_STORE}/${NAME_TO_STORE_IN}" ]]; then
|
||||
mv -f ${PATH_TO_STORE}/${NAME_TO_STORE_IN} ${PATH_TO_STORE}/${NAME_TO_STORE_IN}.bak
|
||||
fi
|
||||
touch ${PATH_TO_STORE}/${NAME_TO_STORE_IN}
|
||||
echo $curl_output | jq -r .[] | while read user; do
|
||||
email=$(curl -H 'X-SAPSSE-Forward-Request-To: master' -H 'Authorization: Bearer '${BEARER_TOKEN} "${BASE_URL}/security/api/restsecurity/user?username=$user" 2>/dev/null| jq -r '.email' )
|
||||
echo $email >> ${PATH_TO_STORE}/${NAME_TO_STORE_IN}
|
||||
done
|
||||
@@ -1,16 +0,0 @@
|
||||
#!/bin/sh
|
||||
ADMIN_EMAIL="axel.uhl@sap.com jan.hamann@sapsailing.com"
|
||||
if [ $# -eq 0 ]; then
|
||||
GIT_PATH="/home/wiki/gitwiki"
|
||||
else
|
||||
GIT_PATH=$1
|
||||
fi
|
||||
cd $GIT_PATH
|
||||
git pull >/tmp/wiki-git.out 2>/tmp/wiki-git.err
|
||||
if [ "$?" != "0" ]; then
|
||||
cat /tmp/wiki-git.out /tmp/wiki-git.err | mail -s "Wiki git problem" $ADMIN_EMAIL
|
||||
fi
|
||||
git push >>/tmp/wiki-git.out 2>/tmp/wiki-git.err
|
||||
if [ "$?" != "0" ]; then
|
||||
cat /tmp/wiki-git.out /tmp/wiki-git.err | mail -s "Wiki git problem" $ADMIN_EMAIL
|
||||
fi
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
environments_scripts/repo/usr/local/bin/syncgit
|
||||
@@ -1,48 +0,0 @@
|
||||
#!/bin/bash
|
||||
BEARER_TOKEN="$1"
|
||||
BASE_URL="$2"
|
||||
LOGON_USER_HOME="$3"
|
||||
SSH_DIR="$3/.ssh"
|
||||
EXIT_CODE=0
|
||||
#
|
||||
curl_output=$( curl -H 'X-SAPSSE-Forward-Request-To: master' -H 'Authorization: Bearer '${BEARER_TOKEN} "${BASE_URL}/security/api/restsecurity/users_with_permission?permission=LANDSCAPE:MANAGE:AWS" 2>/dev/null )
|
||||
curl_exit_code=$?
|
||||
if [ "${curl_exit_code}" = "0" ]; then
|
||||
users=$( echo "${curl_output}" | jq -r '.[]' )
|
||||
jq_exit_code=$?
|
||||
if [ "${jq_exit_code}" = "0" ]; then
|
||||
logger -t sailing "Users with LANDSCAPE:MANAGE:AWS permission: ${users}"
|
||||
public_keys=$( for user in ${users}; do
|
||||
ssh_key_curl_output=$(curl -H 'X-SAPSSE-Forward-Request-To: master' -H 'Authorization: Bearer '${BEARER_TOKEN} "${BASE_URL}/landscape/api/landscape/get_ssh_keys_owned_by_user?username[]=${user}" 2>/dev/null )
|
||||
ssh_key_curl_exit_code=$?
|
||||
if [ "${ssh_key_curl_exit_code}" = "0" ]; then
|
||||
echo "${ssh_key_curl_output}" | jq -r '.[].publicKey'
|
||||
ssh_key_jq_exit_code=$?
|
||||
if [ "${ssh_key_jq_exit_code}" != "0" ]; then
|
||||
EXIT_CODE=${ssh_key_jq_exit_code}
|
||||
logger -t sailing "Couldn't parse response of get_ssh_keys_owned_by_user; jq exit code ${ssh_key_jq_exit_code}"
|
||||
fi
|
||||
else
|
||||
EXIT_CODE=${ssh_key_curl_exit_code}
|
||||
logger -t sailing "Couldn't get response of get_ssh_keys_owned_by_user; curl exit code ${ssh_key_corl_exit_code}"
|
||||
fi
|
||||
done | sort -u )
|
||||
logger -t sailing "Obtained public keys: ${public_keys}"
|
||||
if [ ! -f ${SSH_DIR}/authorized_keys.org ]; then
|
||||
# Create a copy of the original authorized_keys file as generated by AWS from the start-up key:
|
||||
logger -t sailing "Saving original authorized_keys file from ${SSH_DIR}"
|
||||
cp ${SSH_DIR}/authorized_keys ${SSH_DIR}/authorized_keys.org
|
||||
fi
|
||||
# Start out with the original AWS-generated authorized_keys file
|
||||
# and append the public SSH keys of all users having LANDSCAPE:MANAGE:AWS permission:
|
||||
echo "$( cat ${SSH_DIR}/authorized_keys.org )
|
||||
${public_keys}" | sort -u >${SSH_DIR}/authorized_keys
|
||||
else
|
||||
EXIT_CODE=${jq_exit_code}
|
||||
logger -t sailing "Couldn't parse response of users_with_permission; jq exit code ${jq_exit_code}"
|
||||
fi
|
||||
else
|
||||
EXIT_CODE=${curl_exit_code}
|
||||
logger -t sailing "Couldn't get response of users_with_permission; curl exit code ${curl_exit_code}"
|
||||
fi
|
||||
exit ${EXIT_CODE}
|
||||
@@ -0,0 +1 @@
|
||||
environments_scripts/repo/usr/local/bin/update_authorized_keys_for_landscape_managers
|
||||
@@ -1,42 +0,0 @@
|
||||
#!/bin/bash
|
||||
BEARER_TOKEN="$1"
|
||||
BASE_URL="$2"
|
||||
LOGON_USER_HOME="$3"
|
||||
LAST_CHANGE_FILE=/var/run/last_change_aws_landscape_managers_ssh_keys
|
||||
# Uncomment the following for production use, with no error output
|
||||
curl_output=$( curl -H 'X-SAPSSE-Forward-Request-To: master' -H 'Authorization: Bearer '${BEARER_TOKEN} "${BASE_URL}/landscape/api/landscape/get_time_point_of_last_change_in_ssh_keys_of_aws_landscape_managers" 2>/dev/null )
|
||||
curl_exit_code=$?
|
||||
if [ "${curl_exit_code}" = "0" ]; then
|
||||
last_change_millis=$( echo "${curl_output}" | jq -r '."timePointOfLastChangeOfSetOfLandscapeManagers-millis"' )
|
||||
jq_exit_code=$?
|
||||
if [ "${jq_exit_code}" = "0" ]; then
|
||||
if [ -f "${LAST_CHANGE_FILE}" ]; then
|
||||
PREVIOUS_CHANGE=$(cat "${LAST_CHANGE_FILE}")
|
||||
if [ -z ${PREVIOUS_CHANGE} ]; then
|
||||
PREVIOUS_CHANGE=0
|
||||
fi
|
||||
else
|
||||
PREVIOUS_CHANGE=0
|
||||
fi
|
||||
if [ -z ${last_change_millis} ]; then
|
||||
logger -t sailing "Empty response from get_time_point_of_last_change_in_ssh_keys_of_aws_landscape_managers; exiting"
|
||||
exit 1
|
||||
else
|
||||
if [ ${PREVIOUS_CHANGE} -lt ${last_change_millis} ]; then
|
||||
logger -t sailing "New SSH key changes for landscape managers (${last_change_millis} newer than ${PREVIOUS_CHANGE})"
|
||||
if update_authorized_keys_for_landscape_managers "${BEARER_TOKEN}" "${BASE_URL}" "${LOGON_USER_HOME}" ; then
|
||||
logger -t sailing "Updating SSH keys for landscape managers successful; updating ${LAST_CHANGE_FILE}"
|
||||
echo ${last_change_millis} >${LAST_CHANGE_FILE}
|
||||
else
|
||||
logger -t sailing "Updating SSH keys for landscape managers failed with exit code $?; not updating ${LAST_CHANGE_FILE}"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
else
|
||||
logger -t sailing "Parsing response of get_time_point_of_last_change_in_ssh_keys_of_aws_landscape_managers failed with exit code ${jq_exit_code}"
|
||||
exit ${jq_exit_code}
|
||||
fi
|
||||
else
|
||||
logger -t sailing "Getting response of get_time_point_of_last_change_in_ssh_keys_of_aws_landscape_managers failed with exit code ${curl_exit_code}"
|
||||
exit ${curl_exit_code}
|
||||
fi
|
||||
@@ -0,0 +1 @@
|
||||
environments_scripts/repo/usr/local/bin/update_authorized_keys_for_landscape_managers_if_changed
|
||||
@@ -1,17 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Purpose: Create a mailing list in PATH_TO_STORE/landscapeManagersMailingList that contains the emails of all landscape managers, ie. those who
|
||||
# have complete admin privileges in the aws environment.
|
||||
BEARER_TOKEN="$1"
|
||||
PATH_TO_STORE="$2"
|
||||
NAME_TO_STORE_IN="landscapeManagersMailingList"
|
||||
BASE_URL="https://security-service.sapsailing.com"
|
||||
curl_output=$( curl -H 'X-SAPSSE-Forward-Request-To: master' -H 'Authorization: Bearer '${BEARER_TOKEN} "${BASE_URL}/security/api/restsecurity/users_with_permission?permission=LANDSCAPE:MANAGE:AWS" 2>/dev/null )
|
||||
if [[ -f "${PATH_TO_STORE}/${NAME_TO_STORE_IN}" ]]; then
|
||||
mv -f ${PATH_TO_STORE}/${NAME_TO_STORE_IN} ${PATH_TO_STORE}/${NAME_TO_STORE_IN}.bak
|
||||
fi
|
||||
touch ${PATH_TO_STORE}/${NAME_TO_STORE_IN}
|
||||
echo $curl_output | jq -r .[] | while read user; do
|
||||
email=$(curl -H 'X-SAPSSE-Forward-Request-To: master' -H 'Authorization: Bearer '${BEARER_TOKEN} "${BASE_URL}/security/api/restsecurity/user?username=$user" 2>/dev/null| jq -r '.email' )
|
||||
echo $email >> ${PATH_TO_STORE}/${NAME_TO_STORE_IN}
|
||||
done
|
||||
@@ -0,0 +1 @@
|
||||
environments_scripts/repo/usr/local/bin/update_landscape_managers_mailing_list.sh
|
||||
Reference in new issue
Block a user