#! /bin/bash RESET="\033[0m" RED="\033[0;31m" CYAN="\033[0;36m" ssh-add -l | grep -q 'no identities' && ssh-add $(ls ~/.ssh/*.pub | sed 's/\.pub.*//g' | tr '\n' ' ') if [ $# -lt 1 ]; then echo "missing passwd" && exit 1 fi sudo -K echo "$1" | sudo -S true &>/dev/null if [ $? -ne 0 ]; then echo "wrong sudo passwd" && exit 1 fi PASSWD=$1 shift function run() { echo -e "$CYAN $1 $RESET" && $1 } function sudo_run() { echo -e "$RED sudo$CYAN $1 $RESET" && sudo $1 } function update_gem() { # cd .gem/ruby/X.Y.0/specifications/ && ls -1 *.gemspec | sed 's/-\([0-9]\+\.\)\+gemspec//' | while read gem; do gem install $gem; done sudo_run "rm -fr /usr/lib/ruby/gems/*" run "/usr/bin/gem update --no-document" run "/usr/bin/gem clean" if [ $(hostname) = "HMSA0065N" -a $(ls -l $GEM_HOME/cache/*.gem 2>/dev/null | wc -l) -gt 0 ] then for gem in $GEM_HOME/cache/*.gem; do gem inabox $gem ; done rm $GEM_HOME/cache/*.gem 2>/dev/null fi } function update_pkgs() { sudo_run "pacman -Scc --noconfirm" sudo_run "pacman -Syu" || return sudo_run "rm /var/cache/pacman/pkg/*" run "find .cache/aurman/ -type d -delete" run "aurman -Sc --noconfirm" run "aurman -Syu" } function check_etc() { sudo_run "find /etc -name *.pacnew" [ -e /etc/.git ] || return run "cd /etc" sudo_run "git status" } function info() { echo uname -a dmesg --level=err,warn -T echo } function synk() { [ -f ~/.unison/asynk.prf ] && echo -e "$RED ** unison asynk $RESET" && unison asynk.prf } function git_pull() { pushd $1 >/dev/null || return echo -e "$CYAN$1$RESET" run "git pull --rebase" || echo -e "$RED FAILED in : $(pwd) $RESET" popd >/dev/null } synk git_pull ~/usr/git/bin git_pull ~/usr/git/vim git_pull ~/usr/git/share update_pkgs update_gem check_etc info sudo -K