From eb1bee32d16da2d737d0c562dc1712cda85982dc Mon Sep 17 00:00:00 2001 From: david Date: Tue, 3 Oct 2017 21:40:47 +0200 Subject: [PATCH] autopush by david@ghost 03.10.2017 21:40 --- myzsh.sh | 35 ++++++++++++----------------------- plugins/david.zsh | 13 +++++++++++-- 2 files changed, 23 insertions(+), 25 deletions(-) diff --git a/myzsh.sh b/myzsh.sh index d52c945..cbb1808 100644 --- a/myzsh.sh +++ b/myzsh.sh @@ -1,3 +1,8 @@ +# +# Main myzsh script +# (runs at shell start) +# + # check if there is canges to be pushed cd $ZSH local SUBMODULE_SYNTAX='' @@ -5,41 +10,25 @@ if [[ $POST_1_7_2_GIT -gt 0 ]]; then SUBMODULE_SYNTAX="--ignore-submodules=dirty" fi if [[ -n $(git status -s ${SUBMODULE_SYNTAX} 2> /dev/null) ]]; then - echo -e "do you want to push myzsh changes? [y/n] \c" + echo -e "[myzsh]: local myzsh repo is dirty. commit & push changes? [y/n] \c" read choice if [ $choice = "y" ]; then git add **/*[^lastrun] - git commit -am "pushzshconfig $(date "+%d.%m.%Y %H:%M")" + git commit -am "autopush by $(whoami)@$(hostname) $(date "+%d.%m.%Y %H:%M")" git push origin master fi fi cd - > /dev/null -# run myzsh update (every 7 days) +# force myzsh update (every 30 days) timestamp=$(date +%s) if [ -r $ZSH/lastrun ];then lastrun=$(cat $ZSH/lastrun) - if [ $((lastrun+604800)) -le $timestamp ]; then - cd $ZSH; git remote -v | grep -i github >> /dev/null - if [ $? -eq 0 ]; then - choice="" - echo "myzsh moved to socialg.it. unfortunately your" - echo "myzsh repository still points to github.com." - echo -e "do you want to fix this? [y/n] \c" - read choice - if [ $choice = "y" ]; then - git remote -v | grep @ >> /dev/null - if [ $? -eq 0 ]; then - git remote rm origin - git remote add origin git@socialg.it:david/myzsh.git - else - git remote rm origin - git remote add origin https://socialg.it/david/myzsh.git - fi - fi - fi - echo "running update of myzsh now.." + if [ $((lastrun+2592000)) -le $timestamp ]; then + echo "[myzsh]: i have not been updated for at least 30 days." + echo "[myzsh]: forcing update now." + cd $ZSH git pull origin master cd - echo $timestamp > $ZSH/lastrun diff --git a/plugins/david.zsh b/plugins/david.zsh index 7568bf9..a0c0fe2 100644 --- a/plugins/david.zsh +++ b/plugins/david.zsh @@ -8,11 +8,11 @@ alias vz='vim ~/.zshrc && source ~/.zshrc' alias vp='vim $ZSH/plugins/david.zsh && source ~/.zshrc' alias vt='vim $ZSH/themes/david.zsh && source ~/.zshrc' alias vi='vim' -alias vless="/usr/share/vim/vim73/macros/less.sh" +alias v='vim' alias publish="python2 -m SimpleHTTPServer" alias push="git push origin master" alias pull="git pull origin master" -alias vpn="sudo openvpn --writepid /var/run/openvpn --config /home/david/.vpn/david.conf" +#alias vpn="sudo openvpn --writepid /var/run/openvpn --config /home/david/.vpn/david.conf" alias aec="sshuttle -vvr 90.146.8.233 192.168.6.0/24 90.146.8.0/26 10.9.0.0/26 10.12.0.0/16 10.2.0.0/26 192.168.3.0/24 10.12.4.0/22" alias home="sshuttle -vvr stargazer.socialnerds.org:2222 10.1.2.0/24" alias dmz="sshuttle -vvr 90.146.8.9 90.146.8.0/26" @@ -139,6 +139,9 @@ pushmyzsh() update() { + # + # OS Upgrade function for various systems. + # #checking for system systems="ubuntu arch solus raspbian" @@ -150,6 +153,7 @@ update() fi done + #trying to update parsed system case $system in ubuntu) echo "Updating Ubuntu.." @@ -170,8 +174,13 @@ update() ;; ?) echo "error: unknown system." + exit 1 ;; esac + if [ $? -ne 0 ]; then + echo "error: something went wrong." + exit 1 + fi }