autopush by david@ghost
This commit is contained in:
parent
fcd0c174a9
commit
62d188a135
167
install.sh
167
install.sh
|
@ -1,108 +1,81 @@
|
||||||
#!/bin/sh
|
#!/bin/bash
|
||||||
|
|
||||||
installdeps()
|
#
|
||||||
{
|
# myzsh installation script
|
||||||
|
#
|
||||||
|
|
||||||
#dependencies
|
#dependencies
|
||||||
readonly deps="git zsh vim curl wget"
|
readonly deps="git zsh vim curl wget"
|
||||||
|
|
||||||
#check for dependencies
|
#check for dependencies
|
||||||
missingdeps=""
|
missingdeps=""
|
||||||
i=0
|
i=0
|
||||||
for dep in $deps; do
|
for dep in $deps; do
|
||||||
if [ $(command -v $dep > /dev/null; echo $?) -ne "0" ]; then
|
if [ $(command -v $dep > /dev/null; echo $?) -ne "0" ]; then
|
||||||
missingdeps="$missingdeps $dep"
|
missingdeps="$missingdeps $dep"
|
||||||
i=$((i+1))
|
i=$((i+1))
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
#try to install unmet dependencies
|
||||||
|
if [ $i -ne 0 ]; then
|
||||||
|
|
||||||
|
#checking for system
|
||||||
|
echo "[myzsh]: installing missing dependencies ($missingdeps)"
|
||||||
|
readonly systems="ubuntu arch raspbian solus"
|
||||||
|
issue="$(cat /etc/issue)"
|
||||||
|
for item in $systems; do
|
||||||
|
echo $issue | grep -i $item
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
system=$item
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
#try to install unmet dependencies
|
case $system in
|
||||||
if [ $i -ne 0 ]; then
|
ubuntu)
|
||||||
|
sudo apt-get update && sudo apt-get install -y $missingdeps
|
||||||
|
;;
|
||||||
|
arch)
|
||||||
|
sudo pacman -Su $missingdeps
|
||||||
|
;;
|
||||||
|
raspbian)
|
||||||
|
sudo apt-get update && sudo apt-get install -y $missingdeps
|
||||||
|
;;
|
||||||
|
solus)
|
||||||
|
sudo eopkg update-repo && sudo eopkg install $missingdeps
|
||||||
|
;;
|
||||||
|
|
||||||
#checking for system
|
?)
|
||||||
readonly systems="ubuntu arch raspbian solus"
|
echo "[myzsh]: i cannot install dependencies. goodbye."
|
||||||
issue="$(cat /etc/issue)"
|
exit 1
|
||||||
for item in $systems; do
|
;;
|
||||||
echo $issue | grep -i $item
|
esac
|
||||||
if [ $? -eq 0 ]; then
|
|
||||||
system=$item
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
case $system in
|
|
||||||
ubuntu)
|
|
||||||
sudo apt-get update && sudo apt-get install -y $missingdeps
|
|
||||||
;;
|
|
||||||
arch)
|
|
||||||
sudo pacman -Su $missingdeps
|
|
||||||
;;
|
|
||||||
raspbian)
|
|
||||||
sudo apt-get update && sudo apt-get install -y $missingdeps
|
|
||||||
;;
|
|
||||||
solus)
|
|
||||||
sudo eopkg update-repo && sudo eopkg install $missingdeps
|
|
||||||
;;
|
|
||||||
|
|
||||||
?)
|
|
||||||
echo "[myzsh]: i cannot install dependencies. unknown system."
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
fi
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
installmyzsh()
|
|
||||||
{
|
|
||||||
|
|
||||||
rm -rf ~/.myzsh
|
|
||||||
choice="null"
|
|
||||||
while [ $choice != "y" ] && [ $choice != "n" ]; do
|
|
||||||
read -p "[myzsh]: should i clone myzsh writeable? [y/n]" choice
|
|
||||||
if [ "$choice" == "y" ]; then
|
|
||||||
git clone git@socialg.it:david/myzsh.git ~/.myzsh
|
|
||||||
else
|
|
||||||
git clone https://socialg.it/david/myzsh.git ~/.myzsh
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
echo 'ZSH="$HOME/.myzsh"' > ~/.zshrc
|
|
||||||
echo 'THEME="david"' >> ~/.zshrc
|
|
||||||
echo 'plugins=(david)' >> ~/.zshrc
|
|
||||||
echo 'source $ZSH/myzsh.sh' >> ~/.zshrc
|
|
||||||
echo "export PATH=$PATH" >> ~/.zshrc
|
|
||||||
|
|
||||||
cat /etc/passwd | grep ~ | grep "/bin/zsh"
|
|
||||||
#set default shell if not set already
|
|
||||||
if [ $? -eq 1 ]; then
|
|
||||||
read -p "[myzsh]: time to change your default shell to /bin/zsh"
|
|
||||||
sudo vim /etc/passwd
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#start of script
|
|
||||||
|
|
||||||
|
|
||||||
if [ -d ~/.myzsh ]; then
|
|
||||||
choice="null"
|
|
||||||
echo "[myzsh]: it seems i have already been set up."
|
|
||||||
read -p "[myzsh]: should i cleanup & reinstall? [y/n]" choice
|
|
||||||
if [ "$choice" == "y" ]; then
|
|
||||||
installdeps
|
|
||||||
installmyzsh
|
|
||||||
else
|
|
||||||
echo "[myzsh]: updating instead."
|
|
||||||
cd ~/.myzsh
|
|
||||||
git pull origin master
|
|
||||||
cd -
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
installdeps
|
|
||||||
installmyzsh
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#end of script
|
#install
|
||||||
|
echo "[myzsh]: cleaning up previous installations."
|
||||||
|
rm -rf ~/.myzsh
|
||||||
|
|
||||||
|
echo "[myzsh]: downloading repository."
|
||||||
|
if [ -r ~/.ssh/id_rsa ]; then
|
||||||
|
git clone git@socialg.it:david/myzsh.git ~/.myzsh
|
||||||
|
else
|
||||||
|
git clone https://socialg.it/david/myzsh.git ~/.myzsh
|
||||||
|
fi
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "[myzsh]: i cannot clone repository. goodbye."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
#config
|
||||||
|
echo "[myzsh]: setting up config."
|
||||||
|
echo 'ZSH="$HOME/.myzsh"' > ~/.zshrc
|
||||||
|
echo 'THEME="david"' >> ~/.zshrc
|
||||||
|
echo 'plugins=(david)' >> ~/.zshrc
|
||||||
|
echo 'source $ZSH/myzsh.sh' >> ~/.zshrc
|
||||||
|
echo "export PATH=$PATH" >> ~/.zshrc
|
||||||
|
|
||||||
|
echo "[myzsh]: successfully installed."
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
|
10
myzsh.sh
10
myzsh.sh
|
@ -3,6 +3,13 @@
|
||||||
# (runs at shell start)
|
# (runs at shell start)
|
||||||
#
|
#
|
||||||
|
|
||||||
|
# check for default shell
|
||||||
|
cat /etc/passwd | grep ~ | grep "/bin/zsh" > /dev/null
|
||||||
|
if [ $? -eq 1 ]; then
|
||||||
|
echo "[myzsh]: you should set me as your default shell."
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
# 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=''
|
||||||
|
@ -10,7 +17,8 @@ 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 "[myzsh]: local myzsh repo is dirty. commit and push changes? [y/n] \c"
|
choice="null"
|
||||||
|
echo -n "[myzsh]: local myzsh repo is dirty. commit and push changes? [y/n]"
|
||||||
read choice
|
read choice
|
||||||
if [ $choice = "y" ]; then
|
if [ $choice = "y" ]; then
|
||||||
git add **/*[^lastrun]
|
git add **/*[^lastrun]
|
||||||
|
|
Reference in New Issue