Loading sync.sh +23 −9 Original line number Diff line number Diff line #!/usr/bin/env sh die() { RED='\033[0;31m' NC='\033[0m' # No Color GREEN='\033[0;32m' YELLOW='\033[0;33m' NC='\033[39m' # No Color die() { echo -e '\[ '"${RED}$1${NC}"' ]/' exit 1 } header_warning() { echo -e '/[ '"${YELLOW}$1${NC}"' ]\' } footer_success() { echo -e '\[ '"${GREEN}$1${NC}"' ]/' } rm -rvf * || die "Couldn't remove files" if [ -n "$OPENWRT_GIT_URL" ]; then git clone "$OPENWRT_GIT_URL" . > /dev/null || die "Couldn't clone repo" git config user.email "${OPENWRT_GIT_EMAIL:-openwrt@example.com}" > /dev/null || die "Couldn't set email" git config user.name "${OPENWRT_GIT_NAME:-OpenWRT Git bot}" > /dev/null || die "Couldn't set name" git clone -q "$OPENWRT_GIT_URL" . || die "Couldn't clone repo" git config --global user.email "${OPENWRT_GIT_EMAIL:-openwrt@example.com}" || die "Couldn't set email" git config --global user.name "${OPENWRT_GIT_NAME:-OpenWRT Git bot}" || die "Couldn't set name" while true; do git reset --hard > /dev/null || die "Couldn't reset repo" git pull > /dev/null || die "Couldn't pull repo" git reset -q --hard || die "Couldn't reset repo" git pull -q || die "Couldn't pull repo" LC_ALL=C.UTF-8 rsync -qax --delete-after --exclude '*-opkg' -e "ssh -p ${OPENWRT_SSH_PORT:-22}" "${OPENWRT_SSH_HOST:-root@192.168.0.1}:/overlay/upper/" overlay/ || die "Couldn't rsync config" git add -A > /dev/null || die "Couldn't add files" if [ -n "$(git status -su)" ]; then git commit -m OpenWRT > /dev/null || die "Couldn't commit changes" git push --force origin HEAD:${OPENWRT_GIT_BRANCH:-remote} || die "Couldn't push changes" header_warning "Updating at $(date -u)" git commit -q -m OpenWRT || die "Couldn't commit changes" git push -q --force origin HEAD:${OPENWRT_GIT_BRANCH:-remote} || die "Couldn't push changes" footer_success "Done at $(date -u)" fi sleep ${OPENWRT_SYNC_INTERVAL:-10} || die "Couldn't sleep correctly" Loading Loading
sync.sh +23 −9 Original line number Diff line number Diff line #!/usr/bin/env sh die() { RED='\033[0;31m' NC='\033[0m' # No Color GREEN='\033[0;32m' YELLOW='\033[0;33m' NC='\033[39m' # No Color die() { echo -e '\[ '"${RED}$1${NC}"' ]/' exit 1 } header_warning() { echo -e '/[ '"${YELLOW}$1${NC}"' ]\' } footer_success() { echo -e '\[ '"${GREEN}$1${NC}"' ]/' } rm -rvf * || die "Couldn't remove files" if [ -n "$OPENWRT_GIT_URL" ]; then git clone "$OPENWRT_GIT_URL" . > /dev/null || die "Couldn't clone repo" git config user.email "${OPENWRT_GIT_EMAIL:-openwrt@example.com}" > /dev/null || die "Couldn't set email" git config user.name "${OPENWRT_GIT_NAME:-OpenWRT Git bot}" > /dev/null || die "Couldn't set name" git clone -q "$OPENWRT_GIT_URL" . || die "Couldn't clone repo" git config --global user.email "${OPENWRT_GIT_EMAIL:-openwrt@example.com}" || die "Couldn't set email" git config --global user.name "${OPENWRT_GIT_NAME:-OpenWRT Git bot}" || die "Couldn't set name" while true; do git reset --hard > /dev/null || die "Couldn't reset repo" git pull > /dev/null || die "Couldn't pull repo" git reset -q --hard || die "Couldn't reset repo" git pull -q || die "Couldn't pull repo" LC_ALL=C.UTF-8 rsync -qax --delete-after --exclude '*-opkg' -e "ssh -p ${OPENWRT_SSH_PORT:-22}" "${OPENWRT_SSH_HOST:-root@192.168.0.1}:/overlay/upper/" overlay/ || die "Couldn't rsync config" git add -A > /dev/null || die "Couldn't add files" if [ -n "$(git status -su)" ]; then git commit -m OpenWRT > /dev/null || die "Couldn't commit changes" git push --force origin HEAD:${OPENWRT_GIT_BRANCH:-remote} || die "Couldn't push changes" header_warning "Updating at $(date -u)" git commit -q -m OpenWRT || die "Couldn't commit changes" git push -q --force origin HEAD:${OPENWRT_GIT_BRANCH:-remote} || die "Couldn't push changes" footer_success "Done at $(date -u)" fi sleep ${OPENWRT_SYNC_INTERVAL:-10} || die "Couldn't sleep correctly" Loading