added a copying script and sudoers.d contribution to allow all users including sailing to copy the /root/mail.properties to server folders

This commit is contained in:
EC2 Server
2021-03-24 15:55:31 +00:00
parent d2fcf29a3e
commit ccbfb24748
3 changed files with 28 additions and 0 deletions
+22
View File
@@ -0,0 +1,22 @@
#!/bin/bash
RELATIVE_SERVER_DIR=$1
MAIL_PROPERTIES=mail.properties
ROOT_MAIL_PROPERTIES=/root/${MAIL_PROPERTIES}
SAILING_USER=sailing
SERVER_DIR=/home/${SAILING_USER}/servers/${RELATIVE_SERVER_DIR}
CONFIGURATION_DIR=${SERVER_DIR}/configuration
SAILING_MAIL_PROPERTIES=${CONFIGURATION_DIR}/${MAIL_PROPERTIES}
if [ -f "${ROOT_MAIL_PROPERTIES}" ]; then
echo "Found ${ROOT_MAIL_PROPERTIES}. Starting to copy to ${SAILING_MAIL_PROPERTIES}"
mkdir -p "${SERVER_DIR}"
chown ${SAILING_USER} ${SERVER_DIR}
chgrp ${SAILING_USER} ${SERVER_DIR}
mkdir -p "${CONFIGURATION_DIR}"
chown ${SAILING_USER} ${CONFIGURATION_DIR}
chgrp ${SAILING_USER} ${CONFIGURATION_DIR}
cp ${ROOT_MAIL_PROPERTIES} ${SAILING_MAIL_PROPERTIES}
chown ${SAILING_USER} ${SAILING_MAIL_PROPERTIES}
chgrp ${SAILING_USER} ${SAILING_MAIL_PROPERTIES}
else
echo "Did not find ${ROOT_MAIL_PROPERTIES}. Cannot copy."
fi
@@ -0,0 +1 @@
ALL ALL=NOPASSWD: /usr/local/bin/cp_root_mail_properties
+5
View File
@@ -41,6 +41,11 @@ start_tmux() {
start_servers() {
/usr/local/bin/update_authorized_keys_for_landscape_managers $( cat ${SSH_KEY_READER_BEARER_TOKEN} ) 2>&1 >>/var/log/sailing.err
cp /home/sailing/code/configuration/cp_root_mail_properties /usr/local/bin
chown root /usr/local/bin/cp_root_mail_properties
chgrp root /usr/local/bin/cp_root_mail_properties
chmod 755 /usr/local/bin/cp_root_mail_properties
cp /home/sailing/code/configuration/cp_root_mail_properties_sudoers /etc/sudoers.d
if which $EC2_METADATA_CMD && $EC2_METADATA_CMD -d | sed "s/user-data\: //g" | grep "^image-upgrade$"; then
echo "Found image-upgrade in EC2 user data; upgrading image, then probably shutting down for AMI creation depending on the no-shutdown user data string..." >>/var/log/sailing.err
$GIT_REPOSITORY/configuration/imageupgrade.sh