Commit 3d6134de authored by Cooper, Caleb's avatar Cooper, Caleb

Fixed inconsistent spacing.

parent b3844179
......@@ -12,97 +12,97 @@ func_rse_exit_fail() {
}
func_rse_docker_cleanup() {
if [[ ! 'docker' =~ $(groups) ]]; then
sudo usermod -a -G docker "${USER}"
fi
sudo docker stop $(docker ps -aq) 2>/dev/null || true
sudo docker rm $(docker ps -a -q) 2>/dev/null || true
sudo docker rmi $(docker images -q) 2>/dev/null || true
sudo docker image prune -fa || sudo systemctl restart docker
sudo docker system prune -fa || sudo systemctl restart docker
if [[ ! 'docker' =~ $(groups) ]]; then
sudo usermod -a -G docker "${USER}"
fi
sudo docker stop $(docker ps -aq) 2>/dev/null || true
sudo docker rm $(docker ps -a -q) 2>/dev/null || true
sudo docker rmi $(docker images -q) 2>/dev/null || true
sudo docker image prune -fa || sudo systemctl restart docker
sudo docker system prune -fa || sudo systemctl restart docker
}
func_rse_docker_build_push() {
while getopts ":t:f:" opt; do
case ${opt} in
t) TAG="/${OPTARG}";;
f) FILE="${OPTARG}";;
esac
done
COMMIT_REF=$(echo "$CI_COMMIT_REF_NAME" | tr '[:upper:]' '[:lower:]' | tr '/' '_' | sed -e 's/^master$/latest/')
if [[ ${COMMIT_REF} = 'latest' ]]; then
COMMIT_REF=":${COMMIT_REF}"
else
COMMIT_REF="/${COMMIT_REF}"
fi
sudo docker build -f "${FILE}" -t ${CI_REGISTRY,,}/${CI_PROJECT_PATH,,}${TAG,,}${COMMIT_REF,,} .
sudo docker login --username=$CI_REGISTRY_USER --password=$CI_REGISTRY_PASSWORD $CI_REGISTRY
sudo docker push ${CI_REGISTRY,,}/${CI_PROJECT_PATH,,}${TAG,,}${COMMIT_REF,,}
while getopts ":t:f:" opt; do
case ${opt} in
t) TAG="/${OPTARG}";;
f) FILE="${OPTARG}";;
esac
done
COMMIT_REF=$(echo "$CI_COMMIT_REF_NAME" | tr '[:upper:]' '[:lower:]' | tr '/' '_' | sed -e 's/^master$/latest/')
if [[ ${COMMIT_REF} = 'latest' ]]; then
COMMIT_REF=":${COMMIT_REF}"
else
COMMIT_REF="/${COMMIT_REF}"
fi
sudo docker build -f "${FILE}" -t ${CI_REGISTRY,,}/${CI_PROJECT_PATH,,}${TAG,,}${COMMIT_REF,,} .
sudo docker login --username=$CI_REGISTRY_USER --password=$CI_REGISTRY_PASSWORD $CI_REGISTRY
sudo docker push ${CI_REGISTRY,,}/${CI_PROJECT_PATH,,}${TAG,,}${COMMIT_REF,,}
}
func_rse_docker_pull_self() {
while getopts ":t:" opt; do
case ${opt} in
t) TAG="/${OPTARG}";;
esac
done
COMMIT_REF=$(echo "$CI_COMMIT_REF_NAME" | tr '[:upper:]' '[:lower:]' | tr '/' '_' | sed -e 's/^master$/latest/')
if [[ ${COMMIT_REF} = 'latest' ]]; then
COMMIT_REF=":${COMMIT_REF}"
else
COMMIT_REF="/${COMMIT_REF}"
fi
sudo docker login --username=$CI_REGISTRY_USER --password=$CI_REGISTRY_PASSWORD $CI_REGISTRY
sudo docker pull ${CI_REGISTRY,,}/${CI_PROJECT_PATH,,}${TAG,,}${COMMIT_REF,,}
while getopts ":t:" opt; do
case ${opt} in
t) TAG="/${OPTARG}";;
esac
done
COMMIT_REF=$(echo "$CI_COMMIT_REF_NAME" | tr '[:upper:]' '[:lower:]' | tr '/' '_' | sed -e 's/^master$/latest/')
if [[ ${COMMIT_REF} = 'latest' ]]; then
COMMIT_REF=":${COMMIT_REF}"
else
COMMIT_REF="/${COMMIT_REF}"
fi
sudo docker login --username=$CI_REGISTRY_USER --password=$CI_REGISTRY_PASSWORD $CI_REGISTRY
sudo docker pull ${CI_REGISTRY,,}/${CI_PROJECT_PATH,,}${TAG,,}${COMMIT_REF,,}
}
func_rse_make_sudo_account() {
set -x
NEW_ACCOUNT="${1}"
NEW_PASS="${2}"
if [[ ! "$(getent passwd ${NEW_ACCOUNT})" ]]; then
NEW_UID=70000
while [[ "$(getent passwd ${NEW_UID})" ]]; do
NEW_UID=$((NEW_UID + 1))
done
if ! grep "^${NEW_ACCOUNT}" /etc/passwd; then
sudo useradd -m -u ${NEW_UID} -s /bin/bash ${NEW_ACCOUNT}
fi
if [[ ! -e /etc/sudoers.d/${NEW_ACCOUNT} ]]; then
echo "${NEW_ACCOUNT} ALL=(ALL:ALL) NOPASSWD:ALL" > /tmp/${NEW_ACCOUNT}.sudo
sudo chown root:root /tmp/${NEW_ACCOUNT}.sudo
sudo mv /tmp/${NEW_ACCOUNT}.sudo /etc/sudoers.d/${NEW_ACCOUNT}
fi
set -x
NEW_ACCOUNT="${1}"
NEW_PASS="${2}"
if [[ ! "$(getent passwd ${NEW_ACCOUNT})" ]]; then
NEW_UID=70000
while [[ "$(getent passwd ${NEW_UID})" ]]; do
NEW_UID=$((NEW_UID + 1))
done
if ! grep "^${NEW_ACCOUNT}" /etc/passwd; then
sudo useradd -m -u ${NEW_UID} -s /bin/bash ${NEW_ACCOUNT}
fi
if ! echo -e "${NEW_PASS}\n${NEW_PASS}" | sudo passwd ${NEW_ACCOUNT}; then
echo -e "${NEW_PASS}\n${NEW_PASS}" | sudo passwd.orig ${NEW_ACCOUNT}
if [[ ! -e /etc/sudoers.d/${NEW_ACCOUNT} ]]; then
echo "${NEW_ACCOUNT} ALL=(ALL:ALL) NOPASSWD:ALL" > /tmp/${NEW_ACCOUNT}.sudo
sudo chown root:root /tmp/${NEW_ACCOUNT}.sudo
sudo mv /tmp/${NEW_ACCOUNT}.sudo /etc/sudoers.d/${NEW_ACCOUNT}
fi
sudo cat /etc/ssh/sshd_config
sudo sed -i 's/PasswordAuthentication no/PasswordAuthentication yes/' /etc/ssh/sshd_config
sudo sed -i 's/#PasswordAuthentication yes/PasswordAuthentication yes/' /etc/ssh/sshd_config
sudo systemctl reload sshd
fi
if ! echo -e "${NEW_PASS}\n${NEW_PASS}" | sudo passwd ${NEW_ACCOUNT}; then
echo -e "${NEW_PASS}\n${NEW_PASS}" | sudo passwd.orig ${NEW_ACCOUNT}
fi
sudo cat /etc/ssh/sshd_config
sudo sed -i 's/PasswordAuthentication no/PasswordAuthentication yes/' /etc/ssh/sshd_config
sudo sed -i 's/#PasswordAuthentication yes/PasswordAuthentication yes/' /etc/ssh/sshd_config
sudo systemctl reload sshd
}
func_rse_set_authorized_keys() {
ACCOUNT="${1}"
AUTH_KEYS="${2}"
chmod 644 ${AUTH_KEYS}
sudo -u mkdir -p ${HOME}/.ssh
sudo -u ${ACCOUNT} cp "${AUTH_KEYS}" ${HOME}/.ssh/authorized_keys
sudo -u chmod 600 ${HOME}/.ssh/authorized_keys
ACCOUNT="${1}"
AUTH_KEYS="${2}"
chmod 644 ${AUTH_KEYS}
sudo -u mkdir -p ${HOME}/.ssh
sudo -u ${ACCOUNT} cp "${AUTH_KEYS}" ${HOME}/.ssh/authorized_keys
sudo -u chmod 600 ${HOME}/.ssh/authorized_keys
}
func_rse_remove_account() {
ACCOUNT="${1}"
sudo userdel -r ${ACCOUNT}
ACCOUNT="${1}"
sudo userdel -r ${ACCOUNT}
}
func_rse_info_dump() {
echo $PATH
ip a
sudo iptables -L
sudo ss -tunpl
docker ps
export
echo $PATH
ip a
sudo iptables -L
sudo ss -tunpl
docker ps
export
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment