autopush by david@ghost 03.10.2017 21:40
This commit is contained in:
parent
b05e4b42e0
commit
eb1bee32d1
35
myzsh.sh
35
myzsh.sh
|
@ -1,3 +1,8 @@
|
||||||
|
#
|
||||||
|
# Main myzsh script
|
||||||
|
# (runs at shell start)
|
||||||
|
#
|
||||||
|
|
||||||
# check if there is canges to be pushed
|
# check if there is canges to be pushed
|
||||||
cd $ZSH
|
cd $ZSH
|
||||||
local SUBMODULE_SYNTAX=''
|
local SUBMODULE_SYNTAX=''
|
||||||
|
@ -5,41 +10,25 @@ if [[ $POST_1_7_2_GIT -gt 0 ]]; then
|
||||||
SUBMODULE_SYNTAX="--ignore-submodules=dirty"
|
SUBMODULE_SYNTAX="--ignore-submodules=dirty"
|
||||||
fi
|
fi
|
||||||
if [[ -n $(git status -s ${SUBMODULE_SYNTAX} 2> /dev/null) ]]; then
|
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
|
read choice
|
||||||
if [ $choice = "y" ]; then
|
if [ $choice = "y" ]; then
|
||||||
git add **/*[^lastrun]
|
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
|
git push origin master
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
cd - > /dev/null
|
cd - > /dev/null
|
||||||
|
|
||||||
|
|
||||||
# run myzsh update (every 7 days)
|
# force myzsh update (every 30 days)
|
||||||
timestamp=$(date +%s)
|
timestamp=$(date +%s)
|
||||||
if [ -r $ZSH/lastrun ];then
|
if [ -r $ZSH/lastrun ];then
|
||||||
lastrun=$(cat $ZSH/lastrun)
|
lastrun=$(cat $ZSH/lastrun)
|
||||||
if [ $((lastrun+604800)) -le $timestamp ]; then
|
if [ $((lastrun+2592000)) -le $timestamp ]; then
|
||||||
cd $ZSH; git remote -v | grep -i github >> /dev/null
|
echo "[myzsh]: i have not been updated for at least 30 days."
|
||||||
if [ $? -eq 0 ]; then
|
echo "[myzsh]: forcing update now."
|
||||||
choice=""
|
cd $ZSH
|
||||||
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.."
|
|
||||||
git pull origin master
|
git pull origin master
|
||||||
cd -
|
cd -
|
||||||
echo $timestamp > $ZSH/lastrun
|
echo $timestamp > $ZSH/lastrun
|
||||||
|
|
|
@ -8,11 +8,11 @@ alias vz='vim ~/.zshrc && source ~/.zshrc'
|
||||||
alias vp='vim $ZSH/plugins/david.zsh && source ~/.zshrc'
|
alias vp='vim $ZSH/plugins/david.zsh && source ~/.zshrc'
|
||||||
alias vt='vim $ZSH/themes/david.zsh && source ~/.zshrc'
|
alias vt='vim $ZSH/themes/david.zsh && source ~/.zshrc'
|
||||||
alias vi='vim'
|
alias vi='vim'
|
||||||
alias vless="/usr/share/vim/vim73/macros/less.sh"
|
alias v='vim'
|
||||||
alias publish="python2 -m SimpleHTTPServer"
|
alias publish="python2 -m SimpleHTTPServer"
|
||||||
alias push="git push origin master"
|
alias push="git push origin master"
|
||||||
alias pull="git pull 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 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 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"
|
alias dmz="sshuttle -vvr 90.146.8.9 90.146.8.0/26"
|
||||||
|
@ -139,6 +139,9 @@ pushmyzsh()
|
||||||
|
|
||||||
update()
|
update()
|
||||||
{
|
{
|
||||||
|
#
|
||||||
|
# OS Upgrade function for various systems.
|
||||||
|
#
|
||||||
|
|
||||||
#checking for system
|
#checking for system
|
||||||
systems="ubuntu arch solus raspbian"
|
systems="ubuntu arch solus raspbian"
|
||||||
|
@ -150,6 +153,7 @@ update()
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
#trying to update parsed system
|
||||||
case $system in
|
case $system in
|
||||||
ubuntu)
|
ubuntu)
|
||||||
echo "Updating Ubuntu.."
|
echo "Updating Ubuntu.."
|
||||||
|
@ -170,8 +174,13 @@ update()
|
||||||
;;
|
;;
|
||||||
?)
|
?)
|
||||||
echo "error: unknown system."
|
echo "error: unknown system."
|
||||||
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "error: something went wrong."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Reference in New Issue