57 lines
2.0 KiB
Bash
57 lines
2.0 KiB
Bash
#!/bin/bash
|
|
## author : Dryusdan
|
|
## date : 15/02/2020
|
|
## description : A MySQL dumper
|
|
## usage : ./mysqlbackup.sh /BASE/BACKUP/FOLDER RETENTION USERNAME PASSWORD HOST
|
|
|
|
## Bash strict mode ####################################
|
|
set -o errexit # abort on nonzero exitstatus
|
|
set -o pipefail # don't hide errors within pipes
|
|
|
|
#set -o nounset # abort on unbound variable
|
|
|
|
## Bash color ##########################################
|
|
# Set colors
|
|
RED='\033[0;31m'
|
|
GREEN='\033[00;32m'
|
|
YELLOW='\033[00;33m'
|
|
BLUE='\033[00;34m'
|
|
PURPLE='\033[00;35m'
|
|
CYAN='\033[00;36m'
|
|
LIGHTGRAY='\033[00;37m'
|
|
LRED='\033[01;31m'
|
|
LGREEN='\033[01;32m'
|
|
LYELLOW='\033[01;33m'
|
|
LBLUE='\033[01;34m'
|
|
LPURPLE='\033[01;35m'
|
|
LCYAN='\033[01;36m'
|
|
WHITE='\033[01;37m'
|
|
NC='\033[0m' # No Color
|
|
|
|
## Logs ################################################
|
|
readonly SCRIPTNAME="$(basename "$0")"
|
|
readonly SCRIPTDIR=$(pwd)
|
|
info() { echo -e "${LBLUE}[INFO] $* ${NC}" | logger --tag "${SCRIPTNAME}" --stderr ; }
|
|
warning() { echo -e "${YELLOW}[WARNING] $* ${NC}" | logger --tag "${SCRIPTNAME}" --stderr ; }
|
|
error() { echo -e "${LRED}[ERROR] $* ${NC}" | logger --tag "${SCRIPTNAME}" --stderr ; }
|
|
fatal() { echo -e "${RED}[FATAL] $* ${NC}" | logger --tag "${SCRIPTNAME}" --stderr ; exit 1 ; }
|
|
|
|
## Script #############################################
|
|
info "Create VM"
|
|
${SCRIPTDIR}/hcloud server create --name jitsi-tst --label server=jitsi --image 5924233 --firewall 23945 --type 1 --location nbg1 --ssh-key 613376 --ssh-key 3207915 --user-data-from-file cloud-init
|
|
|
|
info "Get IP"
|
|
IP=$(${SCRIPTDIR}/hcloud server list -o columns=ipv4 -o noheader -l server=jitsi)
|
|
|
|
info "Sed it on dns"
|
|
sed -i "s/#- meet.dryusdan.net./ - meet 300 IN A ${IP}/" /home/ansible/Ansible/host_vars/mul/nsd.yml
|
|
echo "${IP}" > ${SCRIPTDIR}/actualIP
|
|
cd /home/ansible/Ansible/
|
|
ansible-playbook -i hosts nsd.yml --limit=mul
|
|
|
|
info "Wait 128 seconds"
|
|
sleep 128
|
|
|
|
info "Connect on server and run Docker"
|
|
ssh -o StrictHostKeyChecking=no root@${IP} "cd /root/jitsi; docker-compose up -d"
|