From ba321657e0e724082df206857f80ca08c4d999dc Mon Sep 17 00:00:00 2001 From: Evgeny Zinoviev Date: Sun, 11 Jun 2023 04:29:14 +0300 Subject: misc/scripts: reorganize files --- .../usr/local/bin/homekit_ipcam_capture_restart.sh | 7 ++ .../local/bin/homekit_ipcam_rtsp2hls_restart.sh | 8 ++ .../local/bin/homekit_make_netns_per_upstream.sh | 38 +++++++ .../usr/local/bin/homekit_sunxi_h3_i2c_reset.sh | 25 +++++ .../usr/local/bin/homekit_sunxi_setup_amixer.sh | 114 +++++++++++++++++++++ .../local/bin/homekit_sync_recordings_to_remote.sh | 72 +++++++++++++ .../usr/local/bin/clickhouse_backup.sh | 31 ++++++ .../usr/local/bin/remove_old_recordings.sh | 5 + .../homekit_ipcam_capture_restart.sh | 7 -- .../homekit_ipcam_rtsp2hls_restart.sh | 8 -- .../homekit_make_netns_per_upstream.sh | 38 ------- .../homekit_sunxi_h3_i2c_reset.sh | 25 ----- .../homekit_sunxi_setup_amixer.sh | 114 --------------------- .../homekit_sync_recordings_to_remote.sh | 72 ------------- misc/scripts/remote_server/clickhouse_backup.sh | 31 ------ .../scripts/remote_server/remove_old_recordings.sh | 5 - 16 files changed, 300 insertions(+), 300 deletions(-) create mode 100755 misc/home_linux_boards/usr/local/bin/homekit_ipcam_capture_restart.sh create mode 100755 misc/home_linux_boards/usr/local/bin/homekit_ipcam_rtsp2hls_restart.sh create mode 100755 misc/home_linux_boards/usr/local/bin/homekit_make_netns_per_upstream.sh create mode 100755 misc/home_linux_boards/usr/local/bin/homekit_sunxi_h3_i2c_reset.sh create mode 100755 misc/home_linux_boards/usr/local/bin/homekit_sunxi_setup_amixer.sh create mode 100755 misc/home_linux_boards/usr/local/bin/homekit_sync_recordings_to_remote.sh create mode 100755 misc/remote_server/usr/local/bin/clickhouse_backup.sh create mode 100755 misc/remote_server/usr/local/bin/remove_old_recordings.sh delete mode 100644 misc/scripts/home_linux_boards/homekit_ipcam_capture_restart.sh delete mode 100644 misc/scripts/home_linux_boards/homekit_ipcam_rtsp2hls_restart.sh delete mode 100644 misc/scripts/home_linux_boards/homekit_make_netns_per_upstream.sh delete mode 100644 misc/scripts/home_linux_boards/homekit_sunxi_h3_i2c_reset.sh delete mode 100755 misc/scripts/home_linux_boards/homekit_sunxi_setup_amixer.sh delete mode 100755 misc/scripts/home_linux_boards/homekit_sync_recordings_to_remote.sh delete mode 100644 misc/scripts/remote_server/clickhouse_backup.sh delete mode 100644 misc/scripts/remote_server/remove_old_recordings.sh (limited to 'misc') diff --git a/misc/home_linux_boards/usr/local/bin/homekit_ipcam_capture_restart.sh b/misc/home_linux_boards/usr/local/bin/homekit_ipcam_capture_restart.sh new file mode 100755 index 0000000..85144da --- /dev/null +++ b/misc/home_linux_boards/usr/local/bin/homekit_ipcam_capture_restart.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +for f in $(ls /etc/ipcam_capture.conf.d/ | xargs); do + camera="${f/.conf/}" + echo "restarting $camera" + systemctl restart ipcam_capture@${camera} +done \ No newline at end of file diff --git a/misc/home_linux_boards/usr/local/bin/homekit_ipcam_rtsp2hls_restart.sh b/misc/home_linux_boards/usr/local/bin/homekit_ipcam_rtsp2hls_restart.sh new file mode 100755 index 0000000..61ee623 --- /dev/null +++ b/misc/home_linux_boards/usr/local/bin/homekit_ipcam_rtsp2hls_restart.sh @@ -0,0 +1,8 @@ +#!/bin/bash +cd /etc/ipcam_rtsp2hls.conf.d/ +for f in *-low.conf; do + f=${f/-low.conf/} + echo "restarting $f" + systemctl restart ipcam_rtsp2hls@${f} + systemctl restart ipcam_rtsp2hls@${f}-low +done diff --git a/misc/home_linux_boards/usr/local/bin/homekit_make_netns_per_upstream.sh b/misc/home_linux_boards/usr/local/bin/homekit_make_netns_per_upstream.sh new file mode 100755 index 0000000..fb152fa --- /dev/null +++ b/misc/home_linux_boards/usr/local/bin/homekit_make_netns_per_upstream.sh @@ -0,0 +1,38 @@ +#!/bin/bash + +set -x +set -e + +get_default_iface() { + ip -4 r show default | awk '{print $5}' +} + +declare -A UPSTREAMS=( + [mtsil]=102 + [mtsazov]=100 + [rtazov]=101 +) + +for name in "${!UPSTREAMS[@]}"; do + mark=${UPSTREAMS[$name]} + veth_addr=10.${mark}.1.1 + vpeer_addr=10.${mark}.1.2 + veth_if=veth${name} + vpeer_if=vpeer${name} + + ip netns add $name + ip link add $veth_if type veth peer name $vpeer_if + ip link set $vpeer_if netns $name + ip addr add $veth_addr/24 dev $veth_if + ip link set $veth_if up + + ip netns exec $name ip addr add $vpeer_addr/24 dev $vpeer_if + ip netns exec $name ip link set $vpeer_if up + ip netns exec $name ip link set lo up + ip netns exec $name ip route add default via $veth_addr + + iptables -t mangle -A PREROUTING -s $vpeer_addr/24 -j MARK --set-mark $mark + iptables -t nat -A POSTROUTING -s $vpeer_addr/24 -o "$(get_default_iface)" -j MASQUERADE +done + +sysctl net.ipv4.ip_forward=1 diff --git a/misc/home_linux_boards/usr/local/bin/homekit_sunxi_h3_i2c_reset.sh b/misc/home_linux_boards/usr/local/bin/homekit_sunxi_h3_i2c_reset.sh new file mode 100755 index 0000000..e654dfb --- /dev/null +++ b/misc/home_linux_boards/usr/local/bin/homekit_sunxi_h3_i2c_reset.sh @@ -0,0 +1,25 @@ +#!/bin/sh + +devices="1c2ac00.i2c 1c2b000.i2c" +pins="8 9 28 30" +driver_path="/sys/bus/platform/drivers/mv64xxx_i2c" + +driver_unbind() { + echo -n "$1" > "$driver_path/unbind" +} + +driver_bind() { + echo -n "$1" > "$driver_path/bind" +} + +for dev in $devices; do driver_unbind "$dev"; done +echo "unbind done" + +for pin in pins; do + gpio mode $pin out + gpio write $pin 0 +done +echo "gpio reset done" + +for dev in $devices; do driver_bind "$dev"; done +echo "bind done" \ No newline at end of file diff --git a/misc/home_linux_boards/usr/local/bin/homekit_sunxi_setup_amixer.sh b/misc/home_linux_boards/usr/local/bin/homekit_sunxi_setup_amixer.sh new file mode 100755 index 0000000..5746514 --- /dev/null +++ b/misc/home_linux_boards/usr/local/bin/homekit_sunxi_setup_amixer.sh @@ -0,0 +1,114 @@ +#!/bin/bash + +amixer() { + /usr/bin/amixer "$@" +} + +setup_opi_pc2() { + for v in unmute cap; do + amixer set "Line In" $v + amixer set "Mic1" $v + amixer set "Mic2" $v + done + + for k in "Mic1 Boost" "Line In" "Mic1" "Mic2 Boost" "Mic2"; do + amixer set "$k" "86%" + done +} + +setup_opi_one() { + for v in unmute cap; do + amixer set "Line In" $v + amixer set "Mic1" $v + done + + for k in "Mic1 Boost" "Line In" "Mic1"; do + amixer set "$k" "86%" + done +} + +setup_opi3lts() { + switches=( + "Left DAC Mixer ADCL" + "Left DAC Mixer I2SDACL" + "Left I2S Mixer ADCL" + "Left I2S Mixer I2SDACL" + "Left Input Mixer LINEINL" + "Left Input Mixer MIC1" + "Left Input Mixer MIC2" + "Left Input Mixer OMixerL" + "Left Input Mixer OMixerR" + "Left Input Mixer PhoneN" + "Left Input Mixer PhonePN" + "Left Output Mixer DACL" + "Left Output Mixer DACR" + "Left Output Mixer LINEINL" + "Left Output Mixer MIC1" + "Left Output Mixer MIC2" + "Left Output Mixer PhoneN" + "Left Output Mixer PhonePN" + "Right DAC Mixer ADCR" + "Right DAC Mixer I2SDACR" + "Right I2S Mixer ADCR" + "Right I2S Mixer I2SDACR" + "Right Input Mixer LINEINR" + "Right Input Mixer MIC1" + "Right Input Mixer MIC2" + "Right Input Mixer OMixerL" + "Right Input Mixer OMixerR" + "Right Input Mixer PhoneP" + "Right Input Mixer PhonePN" + "Right Output Mixer DACL" + "Right Output Mixer DACR" + "Right Output Mixer LINEINR" + "Right Output Mixer MIC1" + "Right Output Mixer MIC2" + "Right Output Mixer PhoneP" + "Right Output Mixer PhonePN" + ) + for v in "${switches[@]}"; do + value=on + case "$v" in + *Input*) + value=on + ;; + *Output*) + value=off + ;; + esac + amixer set "$v" $value + done + + to_mute=( + "I2S Mixer ADC" + "I2S Mixer DAC" + "ADC Input" + "DAC Mixer ADC" + "DAC Mxier DAC" # this is not a typo + ) + for v in "${to_mute[@]}"; do + amixer set "$v" "0%" + done + + amixer set "Master" "100%" + amixer set "MIC1 Boost" "100%" + amixer set "MIC2 Boost" "100%" + amixer set "Line Out Mixer" "86%" + amixer set "MIC Out Mixer" "71%" +} + +device="$(tr -d '\0' < /sys/firmware/devicetree/base/model)" +case "$device" in + *"Orange Pi PC 2") + setup_opi_pc2 + ;; + *"Orange Pi One"|*"Orange Pi Lite") + setup_opi_one + ;; + *"OrangePi 3 LTS") + setup_opi3lts + ;; + *) + >&2 echo "error: unidentified device: $device" + ;; +esac diff --git a/misc/home_linux_boards/usr/local/bin/homekit_sync_recordings_to_remote.sh b/misc/home_linux_boards/usr/local/bin/homekit_sync_recordings_to_remote.sh new file mode 100755 index 0000000..cf979d1 --- /dev/null +++ b/misc/home_linux_boards/usr/local/bin/homekit_sync_recordings_to_remote.sh @@ -0,0 +1,72 @@ +#!/bin/bash + +PROGNAME="$0" +NODE_CONFIG="/etc/sound_node.toml" +REMOTE_USER=user +REMOTE_SERVER=solarmon.ru +REMOTE_DIRECTORY=/var/recordings + +set -e + +echoerr() { + >&2 echo "error: $@" +} + +echowarn() { + >&2 echo "warning: $@" +} + +telegram_alert() { + if [ -z "$TG_TOKEN" ] || [ -z "$TG_CHAT_ID" ]; then return; fi + curl -X POST \ + -F "chat_id=${TG_CHAT_ID}" \ + -F "text=$1" \ + "https://api.telegram.org/bot${TG_TOKEN}/sendMessage" +} + +fatal() { + echoerr "$@" + telegram_alert "$PROGNAME: $@" + exit 1 +} + +get_config_var() { + local varname="$1" + cat "$NODE_CONFIG" | grep "^$varname = \"" | awk '{print $3}' | tr -d '"' +} + +get_mp3_count() { + find "$LOCAL_DIR" -mindepth 1 -type f -name "*.mp3" -printf x | wc -c +} + +[ -z "$TG_TOKEN" ] && echowarn "TG_TOKEN is not set" +[ -z "$TG_CHAT_ID" ] && echowarn "TG_CHAT_ID is not set" + +NODE_NAME=$(get_config_var name) +LOCAL_DIR=$(get_config_var storage) + +[ -z "$NODE_NAME" ] && fatal "failed to parse NODE_NAME" +[ -z "$LOCAL_DIR" ] && fatal "failed to parse LOCAL_DIR" + +[ -d "$LOCAL_DIR" ] || fatal "$LOCAL_DIR is not a directory" + +COUNT=$(get_mp3_count) +(( $COUNT < 1 )) && { + echo "seems there's nothing to sync" + exit +} + +cd "$LOCAL_DIR" || fatal "failed to change to $LOCAL_DIR" + +rsync -azPv -e "ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o LogLevel=ERROR" \ + *.mp3 \ + ${REMOTE_USER}@${REMOTE_SERVER}:"${REMOTE_DIRECTORY}/${NODE_NAME}/" \ + --exclude temp.mp3 + +RC=$? + +if [ $RC -eq 0 ]; then + find "$LOCAL_DIR" -name "*.mp3" -type f -mmin +1440 -delete || fatal "find failed to delete old files" +else + fatal "failed to rsync: code $RC" +fi diff --git a/misc/remote_server/usr/local/bin/clickhouse_backup.sh b/misc/remote_server/usr/local/bin/clickhouse_backup.sh new file mode 100755 index 0000000..6e938e4 --- /dev/null +++ b/misc/remote_server/usr/local/bin/clickhouse_backup.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +DIR=/var/lib/clickhouse/backup +MAX_COUNT=3 +NAME=backup_$(date -u +%Y-%m-%d) + +create() { + local name="$1" + clickhouse-backup create "$name" +} + +del() { + local name="$1" + clickhouse-backup delete local "$name" +} + +# create a backup +create "$NAME" + +# compress backup +cd "$DIR" +tar czvf $NAME.tar.gz $NAME + +# delete uncompressed files +del "$NAME" + +# delete old backups +for file in $(ls -t "${DIR}" | tail -n +$(( MAX_COUNT+1 ))); do + echo "removing $file..." + rm "$file" +done \ No newline at end of file diff --git a/misc/remote_server/usr/local/bin/remove_old_recordings.sh b/misc/remote_server/usr/local/bin/remove_old_recordings.sh new file mode 100755 index 0000000..d376572 --- /dev/null +++ b/misc/remote_server/usr/local/bin/remove_old_recordings.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +# to be launched by cron on remote server + +find /var/recordings -type f -mtime +14 -delete diff --git a/misc/scripts/home_linux_boards/homekit_ipcam_capture_restart.sh b/misc/scripts/home_linux_boards/homekit_ipcam_capture_restart.sh deleted file mode 100644 index 85144da..0000000 --- a/misc/scripts/home_linux_boards/homekit_ipcam_capture_restart.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash - -for f in $(ls /etc/ipcam_capture.conf.d/ | xargs); do - camera="${f/.conf/}" - echo "restarting $camera" - systemctl restart ipcam_capture@${camera} -done \ No newline at end of file diff --git a/misc/scripts/home_linux_boards/homekit_ipcam_rtsp2hls_restart.sh b/misc/scripts/home_linux_boards/homekit_ipcam_rtsp2hls_restart.sh deleted file mode 100644 index 61ee623..0000000 --- a/misc/scripts/home_linux_boards/homekit_ipcam_rtsp2hls_restart.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash -cd /etc/ipcam_rtsp2hls.conf.d/ -for f in *-low.conf; do - f=${f/-low.conf/} - echo "restarting $f" - systemctl restart ipcam_rtsp2hls@${f} - systemctl restart ipcam_rtsp2hls@${f}-low -done diff --git a/misc/scripts/home_linux_boards/homekit_make_netns_per_upstream.sh b/misc/scripts/home_linux_boards/homekit_make_netns_per_upstream.sh deleted file mode 100644 index fb152fa..0000000 --- a/misc/scripts/home_linux_boards/homekit_make_netns_per_upstream.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/bash - -set -x -set -e - -get_default_iface() { - ip -4 r show default | awk '{print $5}' -} - -declare -A UPSTREAMS=( - [mtsil]=102 - [mtsazov]=100 - [rtazov]=101 -) - -for name in "${!UPSTREAMS[@]}"; do - mark=${UPSTREAMS[$name]} - veth_addr=10.${mark}.1.1 - vpeer_addr=10.${mark}.1.2 - veth_if=veth${name} - vpeer_if=vpeer${name} - - ip netns add $name - ip link add $veth_if type veth peer name $vpeer_if - ip link set $vpeer_if netns $name - ip addr add $veth_addr/24 dev $veth_if - ip link set $veth_if up - - ip netns exec $name ip addr add $vpeer_addr/24 dev $vpeer_if - ip netns exec $name ip link set $vpeer_if up - ip netns exec $name ip link set lo up - ip netns exec $name ip route add default via $veth_addr - - iptables -t mangle -A PREROUTING -s $vpeer_addr/24 -j MARK --set-mark $mark - iptables -t nat -A POSTROUTING -s $vpeer_addr/24 -o "$(get_default_iface)" -j MASQUERADE -done - -sysctl net.ipv4.ip_forward=1 diff --git a/misc/scripts/home_linux_boards/homekit_sunxi_h3_i2c_reset.sh b/misc/scripts/home_linux_boards/homekit_sunxi_h3_i2c_reset.sh deleted file mode 100644 index e654dfb..0000000 --- a/misc/scripts/home_linux_boards/homekit_sunxi_h3_i2c_reset.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/sh - -devices="1c2ac00.i2c 1c2b000.i2c" -pins="8 9 28 30" -driver_path="/sys/bus/platform/drivers/mv64xxx_i2c" - -driver_unbind() { - echo -n "$1" > "$driver_path/unbind" -} - -driver_bind() { - echo -n "$1" > "$driver_path/bind" -} - -for dev in $devices; do driver_unbind "$dev"; done -echo "unbind done" - -for pin in pins; do - gpio mode $pin out - gpio write $pin 0 -done -echo "gpio reset done" - -for dev in $devices; do driver_bind "$dev"; done -echo "bind done" \ No newline at end of file diff --git a/misc/scripts/home_linux_boards/homekit_sunxi_setup_amixer.sh b/misc/scripts/home_linux_boards/homekit_sunxi_setup_amixer.sh deleted file mode 100755 index 5746514..0000000 --- a/misc/scripts/home_linux_boards/homekit_sunxi_setup_amixer.sh +++ /dev/null @@ -1,114 +0,0 @@ -#!/bin/bash - -amixer() { - /usr/bin/amixer "$@" -} - -setup_opi_pc2() { - for v in unmute cap; do - amixer set "Line In" $v - amixer set "Mic1" $v - amixer set "Mic2" $v - done - - for k in "Mic1 Boost" "Line In" "Mic1" "Mic2 Boost" "Mic2"; do - amixer set "$k" "86%" - done -} - -setup_opi_one() { - for v in unmute cap; do - amixer set "Line In" $v - amixer set "Mic1" $v - done - - for k in "Mic1 Boost" "Line In" "Mic1"; do - amixer set "$k" "86%" - done -} - -setup_opi3lts() { - switches=( - "Left DAC Mixer ADCL" - "Left DAC Mixer I2SDACL" - "Left I2S Mixer ADCL" - "Left I2S Mixer I2SDACL" - "Left Input Mixer LINEINL" - "Left Input Mixer MIC1" - "Left Input Mixer MIC2" - "Left Input Mixer OMixerL" - "Left Input Mixer OMixerR" - "Left Input Mixer PhoneN" - "Left Input Mixer PhonePN" - "Left Output Mixer DACL" - "Left Output Mixer DACR" - "Left Output Mixer LINEINL" - "Left Output Mixer MIC1" - "Left Output Mixer MIC2" - "Left Output Mixer PhoneN" - "Left Output Mixer PhonePN" - "Right DAC Mixer ADCR" - "Right DAC Mixer I2SDACR" - "Right I2S Mixer ADCR" - "Right I2S Mixer I2SDACR" - "Right Input Mixer LINEINR" - "Right Input Mixer MIC1" - "Right Input Mixer MIC2" - "Right Input Mixer OMixerL" - "Right Input Mixer OMixerR" - "Right Input Mixer PhoneP" - "Right Input Mixer PhonePN" - "Right Output Mixer DACL" - "Right Output Mixer DACR" - "Right Output Mixer LINEINR" - "Right Output Mixer MIC1" - "Right Output Mixer MIC2" - "Right Output Mixer PhoneP" - "Right Output Mixer PhonePN" - ) - for v in "${switches[@]}"; do - value=on - case "$v" in - *Input*) - value=on - ;; - *Output*) - value=off - ;; - esac - amixer set "$v" $value - done - - to_mute=( - "I2S Mixer ADC" - "I2S Mixer DAC" - "ADC Input" - "DAC Mixer ADC" - "DAC Mxier DAC" # this is not a typo - ) - for v in "${to_mute[@]}"; do - amixer set "$v" "0%" - done - - amixer set "Master" "100%" - amixer set "MIC1 Boost" "100%" - amixer set "MIC2 Boost" "100%" - amixer set "Line Out Mixer" "86%" - amixer set "MIC Out Mixer" "71%" -} - -device="$(tr -d '\0' < /sys/firmware/devicetree/base/model)" -case "$device" in - *"Orange Pi PC 2") - setup_opi_pc2 - ;; - *"Orange Pi One"|*"Orange Pi Lite") - setup_opi_one - ;; - *"OrangePi 3 LTS") - setup_opi3lts - ;; - *) - >&2 echo "error: unidentified device: $device" - ;; -esac diff --git a/misc/scripts/home_linux_boards/homekit_sync_recordings_to_remote.sh b/misc/scripts/home_linux_boards/homekit_sync_recordings_to_remote.sh deleted file mode 100755 index cf979d1..0000000 --- a/misc/scripts/home_linux_boards/homekit_sync_recordings_to_remote.sh +++ /dev/null @@ -1,72 +0,0 @@ -#!/bin/bash - -PROGNAME="$0" -NODE_CONFIG="/etc/sound_node.toml" -REMOTE_USER=user -REMOTE_SERVER=solarmon.ru -REMOTE_DIRECTORY=/var/recordings - -set -e - -echoerr() { - >&2 echo "error: $@" -} - -echowarn() { - >&2 echo "warning: $@" -} - -telegram_alert() { - if [ -z "$TG_TOKEN" ] || [ -z "$TG_CHAT_ID" ]; then return; fi - curl -X POST \ - -F "chat_id=${TG_CHAT_ID}" \ - -F "text=$1" \ - "https://api.telegram.org/bot${TG_TOKEN}/sendMessage" -} - -fatal() { - echoerr "$@" - telegram_alert "$PROGNAME: $@" - exit 1 -} - -get_config_var() { - local varname="$1" - cat "$NODE_CONFIG" | grep "^$varname = \"" | awk '{print $3}' | tr -d '"' -} - -get_mp3_count() { - find "$LOCAL_DIR" -mindepth 1 -type f -name "*.mp3" -printf x | wc -c -} - -[ -z "$TG_TOKEN" ] && echowarn "TG_TOKEN is not set" -[ -z "$TG_CHAT_ID" ] && echowarn "TG_CHAT_ID is not set" - -NODE_NAME=$(get_config_var name) -LOCAL_DIR=$(get_config_var storage) - -[ -z "$NODE_NAME" ] && fatal "failed to parse NODE_NAME" -[ -z "$LOCAL_DIR" ] && fatal "failed to parse LOCAL_DIR" - -[ -d "$LOCAL_DIR" ] || fatal "$LOCAL_DIR is not a directory" - -COUNT=$(get_mp3_count) -(( $COUNT < 1 )) && { - echo "seems there's nothing to sync" - exit -} - -cd "$LOCAL_DIR" || fatal "failed to change to $LOCAL_DIR" - -rsync -azPv -e "ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o LogLevel=ERROR" \ - *.mp3 \ - ${REMOTE_USER}@${REMOTE_SERVER}:"${REMOTE_DIRECTORY}/${NODE_NAME}/" \ - --exclude temp.mp3 - -RC=$? - -if [ $RC -eq 0 ]; then - find "$LOCAL_DIR" -name "*.mp3" -type f -mmin +1440 -delete || fatal "find failed to delete old files" -else - fatal "failed to rsync: code $RC" -fi diff --git a/misc/scripts/remote_server/clickhouse_backup.sh b/misc/scripts/remote_server/clickhouse_backup.sh deleted file mode 100644 index 6e938e4..0000000 --- a/misc/scripts/remote_server/clickhouse_backup.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/bash - -DIR=/var/lib/clickhouse/backup -MAX_COUNT=3 -NAME=backup_$(date -u +%Y-%m-%d) - -create() { - local name="$1" - clickhouse-backup create "$name" -} - -del() { - local name="$1" - clickhouse-backup delete local "$name" -} - -# create a backup -create "$NAME" - -# compress backup -cd "$DIR" -tar czvf $NAME.tar.gz $NAME - -# delete uncompressed files -del "$NAME" - -# delete old backups -for file in $(ls -t "${DIR}" | tail -n +$(( MAX_COUNT+1 ))); do - echo "removing $file..." - rm "$file" -done \ No newline at end of file diff --git a/misc/scripts/remote_server/remove_old_recordings.sh b/misc/scripts/remote_server/remove_old_recordings.sh deleted file mode 100644 index d376572..0000000 --- a/misc/scripts/remote_server/remove_old_recordings.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - -# to be launched by cron on remote server - -find /var/recordings -type f -mtime +14 -delete -- cgit v1.2.3