Loading sync.sh +15 −10 Original line number Diff line number Diff line Loading @@ -3,30 +3,35 @@ 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 '[ '"${RED}$1${NC}"' ]' exit 1 } header_warning() { echo -e '/[ '"${YELLOW}$1${NC}"' ]\' warning() { echo -e '[ '"${YELLOW}$1${NC}"' ]' } footer_success() { echo -e '\[ '"${GREEN}$1${NC}"' ]/' notify() { echo -e '[ '"${BLUE}$1${NC}"' ]' } success() { echo -e '[ '"${GREEN}$1${NC}"' ]' } warning "Starting at $(date -u)" rm -rvf * || die "Couldn't remove files" if [ -n "$OPENWRT_GIT_URL" ]; then 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" git clone -q "$OPENWRT_GIT_URL" . || die "Couldn't clone repo" notify "Enterng main loop $(date -u)" while true; do git reset -q --hard || die "Couldn't reset repo" git pull -q || die "Couldn't pull repo" Loading @@ -35,15 +40,15 @@ if [ -n "$OPENWRT_GIT_URL" ]; then git add -A > /dev/null || die "Couldn't add files" if [ -n "$(git status -su)" ]; then header_warning "Updating at $(date -u)" 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)" success "Updated at $(date -u)" fi sleep ${OPENWRT_SYNC_INTERVAL:-10} || die "Couldn't sleep correctly" done die "Somebody has escaped from endless cycle" else die "OPENWRT_GIT_URL is not configured" fi Loading
sync.sh +15 −10 Original line number Diff line number Diff line Loading @@ -3,30 +3,35 @@ 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 '[ '"${RED}$1${NC}"' ]' exit 1 } header_warning() { echo -e '/[ '"${YELLOW}$1${NC}"' ]\' warning() { echo -e '[ '"${YELLOW}$1${NC}"' ]' } footer_success() { echo -e '\[ '"${GREEN}$1${NC}"' ]/' notify() { echo -e '[ '"${BLUE}$1${NC}"' ]' } success() { echo -e '[ '"${GREEN}$1${NC}"' ]' } warning "Starting at $(date -u)" rm -rvf * || die "Couldn't remove files" if [ -n "$OPENWRT_GIT_URL" ]; then 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" git clone -q "$OPENWRT_GIT_URL" . || die "Couldn't clone repo" notify "Enterng main loop $(date -u)" while true; do git reset -q --hard || die "Couldn't reset repo" git pull -q || die "Couldn't pull repo" Loading @@ -35,15 +40,15 @@ if [ -n "$OPENWRT_GIT_URL" ]; then git add -A > /dev/null || die "Couldn't add files" if [ -n "$(git status -su)" ]; then header_warning "Updating at $(date -u)" 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)" success "Updated at $(date -u)" fi sleep ${OPENWRT_SYNC_INTERVAL:-10} || die "Couldn't sleep correctly" done die "Somebody has escaped from endless cycle" else die "OPENWRT_GIT_URL is not configured" fi