-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathake.sh
128 lines (107 loc) · 2.96 KB
/
ake.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
# zsh
# Check if user is root
# if [ $(id -u) != "0" ]; then
# echo "Error: You must be root to run this script!"
# exit 1
# fi
arg1=$1
arg2=$2
install_zsh(){
# install package
apt-get -y install zsh && sh -c "$(wget https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"
}
init(){
# apt-get -y install git zsh
echo '暂不支持该功能'
}
tag(){
#get highest tag number
# git fetch --tags
VERSION=`git tag --sort=taggerdate | tail -1`
if [ !$VERSION ]
then
VERSION='v0.0.0'
fi
# VERSION=`git describe --abbrev=0 --tags`
arg1=$1
#replace . with space so can split into an array
VERSION_BITS=(${VERSION//./ })
#get number parts and increase last one by 1
VNUM1=${VERSION_BITS[0]}
VNUM2=${VERSION_BITS[1]}
VNUM3=${VERSION_BITS[2]}
VNUM3=$((VNUM3+1))
#create new tag
NEW_TAG="$VNUM1.$VNUM2.$VNUM3"
echo "Updating $VERSION to $NEW_TAG"
while :;do
message=""
read -p "Enter tag message: " message
if [ "${message}" = "" ]; then
echo "Error: message can't be NULL!!"
else
break
fi
done
#get current hash and see if it already has a tag
GIT_COMMIT=`git rev-parse HEAD`
NEEDS_TAG=`git describe --contains $GIT_COMMIT`
#only tag if no tag already (would be better if the git describe command above could have a silent option)
if [ -z "$NEEDS_TAG" ]; then
echo "Tagged with $NEW_TAG (Ignoring fatal:cannot describe - this means commit is untagged) "
git tag -a $NEW_TAG -m"${message}"
git push --tags
else
echo "Already a tag on this commit"
fi
}
install_docker(){
wget -qO- https://get.docker.com/ | sh && sudo pip install -U docker-compose
}
install_node(){
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.6/install.sh | bash
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
nvm install node $1
}
stark(){
echo "hi ${arg1}"
}
addUser(){
if [ -z ${User} ]; then
echo "==========================="
User="stark"
Echo_Yellow "Please enter username for this system"
read -p "Please enter: " User
if [ "${User}" = "" ]; then
echo "NO input, will be generated randomly."
fi
fi
echo "your enter username:" ${User}
useradd ${User}
mkdir -p /home/${User}
chown -R ${User}:${User} /home/${User}
gpasswd -a ${User} sudo
usermod -s /bin/bash ${User}
passwd ${Passwd}
}
case "${arg1}" in
init) init ;;
tag) tag ${arg2};;
zsh) install_zsh ;;
stark) stark ${arg1} ;;
docker) install_docker ;;
addUser) addUser ${arg2} ;;
*)
echo "+-------------------------------------------+"
echo "| Welcome to ake sh |"
echo "+-------------------------------------------+"
echo "| https://shudong.wang |"
echo "+-------------------------------------------+"
echo "Usage: ake { zsh|init|docer| addUser}"
;;
esac
exit