From 2edb76a059f6cac511199914033f17a55cdfbe0f Mon Sep 17 00:00:00 2001 From: Dmitriy Safronov Date: Wed, 15 Jan 2025 11:39:00 +0400 Subject: [PATCH] update Signed-off-by: Dmitriy Safronov --- entrypoint.sh | 16 +++++++--------- sync.sh | 26 ++------------------------ 2 files changed, 9 insertions(+), 33 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 5f7037e..b680140 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,18 +1,16 @@ #!/usr/bin/env sh die() { - RED='\033[0;31m' - NC='\033[0m' # No Color - echo -e '\[ '"${RED}$1${NC}"' ]/' + echo -e "* $1" exit 1 } -test -n "$OPENWRT_SSH_CONFIG" && echo "$OPENWRT_SSH_CONFIG" > /opt/config -test -n "$OPENWRT_SSH_KEY" && echo "$OPENWRT_SSH_KEY" > /opt/id_rsa -test -n "$OPENWRT_SSH_KNOWN_HOSTS" && echo "$OPENWRT_SSH_KNOWN_HOSTS" > /opt/known_hosts +test -n "$OPENWRT_SSH_CONFIG" && echo "$OPENWRT_SSH_CONFIG" > /opt/config +test -n "$OPENWRT_SSH_KEY" && echo "$OPENWRT_SSH_KEY" > /opt/id_rsa +test -n "$OPENWRT_SSH_KNOWN_HOSTS" && echo "$OPENWRT_SSH_KNOWN_HOSTS" > /opt/known_hosts -rsync -a /opt/ /home/openwrt/.ssh/ || die "Couldn't rsync user ssh settings" +rsync -a /opt/ /home/openwrt/.ssh/ || die "Couldn't rsync user ssh settings" chown -R openwrt:openwrt /home/openwrt/.ssh || die "Couldn't change ownership for user ssh settings" -chmod -R a-rwx,u+rwX /home/openwrt/.ssh || die "Couldn't change access rights for user ssh settings" +chmod -R a-rwx,u+rwX /home/openwrt/.ssh || die "Couldn't change access rights for user ssh settings" -exec sudo -u openwrt -g openwrt -E -H sh -c 'exec sh /sync.sh' || die "Couldn't run sync sript as user" +exec sudo -u openwrt -g openwrt -E -H sh -c 'exec sh /sync.sh' || die "Couldn't run sync script as user" diff --git a/sync.sh b/sync.sh index c117b57..5cf1e0a 100644 --- a/sync.sh +++ b/sync.sh @@ -1,32 +1,10 @@ #!/usr/bin/env sh -RED='\033[0;31m' -GREEN='\033[0;32m' -YELLOW='\033[0;33m' -BLUE='\033[0;34m' -NC='\033[39m' # No Color - die() { - echo -e '[ '"${RED}$1${NC}"' ]' + echo -e "* $1" exit 1 } -warning() { - echo -e '[ '"${YELLOW}$1${NC}"' ]' -} - -notify() { - echo -e '[ '"${BLUE}$1${NC}"' ]' -} - -success() { - echo -e '[ '"${GREEN}$1${NC}"' ]' -} - -warning "Starting at $(date -u)" - find overlay/ -type f -name .gitkeep -delete -LC_ALL=C.UTF-8 rsync -acxv --no-times --delete-after --exclude '*-opkg' -e "ssh -p ${OPENWRT_SSH_PORT:-22}" overlay/ "${OPENWRT_SSH_HOST:-root@192.168.0.1}:/overlay/upper/" || die "Couldn't rsync config" - -success "Done at $(date -u)" +LC_ALL=C.UTF-8 rsync -acxv --no-times --delete-after --exclude '*-opkg' -e "ssh -p ${OPENWRT_SSH_PORT:-22}" overlay/ "${OPENWRT_SSH_HOST:-root@192.168.1.1}:/overlay/upper/" || die "Couldn't rsync config" -- GitLab