Files
lisglosips/infra/server-a/s30/lisglosips-opensips-config-restore.sh

24 lines
710 B
Bash
Executable File

#!/bin/bash
set -euo pipefail
if [ "$#" -ne 1 ]; then
echo "usage: $0 /path/to/opensips.cfg.backup" >&2
exit 64
fi
source_cfg="$1"
test -f "$source_cfg"
stamp="$(date -u +%Y%m%dT%H%M%SZ)"
backup_dir="/var/backups/lisglosips-s30/$stamp"
install -d -o root -g root -m 0700 "$backup_dir"
install -o root -g root -m 0600 /etc/opensips/opensips.cfg "$backup_dir/opensips.cfg.pre-restore"
install -o root -g root -m 0600 "$source_cfg" "$backup_dir/opensips.cfg.candidate"
opensips -C -f "$backup_dir/opensips.cfg.candidate"
install -o root -g opensips -m 0640 "$backup_dir/opensips.cfg.candidate" /etc/opensips/opensips.cfg
systemctl restart opensips
systemctl is-active --quiet opensips
echo "$backup_dir"