#!/bin/bash YUM=/usr/bin/yum SYNC_CTL_DIR=/root/.sync_ctl ask_yn () { local msg=$1 echo -n "$msg" echo -n " [y/N]: " local answer read answer [ "$answer" = "Y" -o "$answer" = "y" ] && return 0 return 1 } get_last_yum_transaction_id () { $YUM history addon-info last | sed -n '/Transaction ID/s/[^0-9]\+\([0-9]\+\)/\1/p' } red_output () { echo -en "\033[1;31m" } normal_output () { echo -en "\033[0;39m" } # Normal users should not use yum if [ $( id -u) -ne 0 ]; then red_output echo "Yum cannot be run under unpriveledged user." normal_output exit 1 fi yum_cmd=$1 # Continue with root yum invocations # check for login WARNING if [ "$yum_cmd" == "synccheck" ]; then if [ -d "$SYNC_CTL_DIR" ]; then trans_num=$( ls -1 "$SYNC_CTL_DIR" | wc -l ) [ $trans_num -eq 0 ] && exit 0 red_output cat < To rollback transaction: yum history undo When conflict is solved remove ID file from directory. END normal_output fi exit 0 fi case $yum_cmd in # Allow info/search and history manipulations info|list|search|makecache|provides|repolist|version|check|history) $YUM $@ exit $? ;; nodesync) # Allow 'yum nodesync' command which has special meaning $YUM makecache fast if [ "$2" = "config" ]; then $YUM -y update knu-config* elif [ "$2" = "deps" ]; then $YUM -y update knu-wn-deps elif [ "$2" = "hkr" ]; then $YUM -y update --disablerepo=* --enablerepo=blackjack-HKR-* elif [ "$2" = "all" ]; then $YUM -y update else $YUM -y repo-pkgs blackjack-HKR-x86_64 upgrade $YUM -y repo-pkgs blackjack-HKR-noarch upgrade fi exit $? ;; esac # In case of ordinary yum invocation print really HUGE warning red_output cat <