forked from honglt1/Monlor-Tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gitsync.sh
executable file
·165 lines (154 loc) · 3.35 KB
/
gitsync.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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
#!/bin/bash
path=~/Documents/Monlor-Tools
cd $path
[ $? -ne 0 ] && echo "Change directory failed!" && exit
#find . -name '._*' -type f -print -exec rm -rf {} \;
find . -name '.DS_Store' | xargs rm -rf
find . -name '._*' | xargs rm -rf
if [ "`uname -s`" == "Darwin" ]; then
md5=md5
else
md5=md5sum
fi
vtools() {
version=$(cat config/version.txt)
num1=$(echo "$version" | cut -d'.' -f1)
num2=$(echo "$version" | cut -d'.' -f2)
num3=$(echo "$version" | cut -d'.' -f3)
num4=$(echo "$version" | cut -d'.' -f4)
oldver="$num1"."$num2"."$num3"
newver="$num1"."`date +%-m.%-d`"
if [ "$newver" == "$oldver" ]; then
[ -z "$num4" ] && num4=1 || let num4=$num4+1
echo "$newver"."$num4" > config/version.txt
else
echo "$newver" > config/version.txt
fi
}
vapp() {
local appname="$1"
version=$(cat $appname/config/version.txt)
num1=$(echo "$version" | cut -d'.' -f1)
num2=$(echo "$version" | cut -d'.' -f2)
num3=$(echo "$version" | cut -d'.' -f3)
let num3=$num3+1
echo "$num1.$num2.$num3" > $appname/config/version.txt
}
pack() {
local name="$1"
if [ -z "$name" -o "$name" == "-v" -o "$name" == "all" ]; then
[ "$name" == "-v" -o "$2" == "-v" ] && vtools
rm -rf monlor/
rm -rf monlor.tar.gz
mkdir -p monlor/apps/
cp -rf config/ monlor/config
cp -rf scripts/ monlor/scripts
cp -rf web/ monlor/web
if [ -f newinfo.txt ] && [ ! -z "$(cat newinfo.txt)" ]; then
cp -rf newinfo.txt monlor/
fi
#test
# cp install.sh install_test.sh
# if [ "`uname -s`" == "Darwin" ]; then
# sed -i "" 's/Monlor-Tools/Monlor-Test/' install_test.sh
# else
# sed -i 's/Monlor-Tools/Monlor-Test/' install_test.sh
# fi
tar -zcvf monlor.tar.gz monlor/
mv -f monlor.tar.gz appstore/
rm -rf monlor/
fi
if [ ! -z "$name" -a "$name" != "-v" ]; then
#pack app
cd apps/
if [ "$name" == "all" ]; then
ls | while read line
do
[ "$2" == "-v" ] && vapp $line
tar -zcvf $line.tar.gz $line/
done
$md5 ./*.tar.gz > ../md5.txt
else
[ "$2" == "-v" ] && vapp $name
tar -zcvf $name.tar.gz $name/
if [ "`uname -s`" == "Darwin" ]; then
sed -i "" "/$name/d" ../md5.txt
else
sed -i "/$name/d" ../md5.txt
fi
$md5 ./$name.tar.gz >> ../md5.txt
fi
mv -f ./*.tar.gz ../appstore
cd ../
fi
rm -rf version/
rm -rf version.tar.gz
mkdir version
ls apps/ | while read line
do
cp apps/$line/config/version.txt version/$line.txt
done
cp config/version.txt version/tools.txt
tar -zcvf version.tar.gz version/
rm -rf version/
}
localgit() {
git add .
git commit -m "`date +%Y-%m-%d`"
}
github() {
git remote rm origin
git remote add origin https://github.com/monlor/Monlor-Tools.git
git push origin master -f
}
coding() {
git remote rm origin
git remote add origin https://git.coding.net/monlor/Monlor-Tools.git
git push origin master -f
}
testing() {
git remote rm origin
git remote add origin https://git.coding.net/monlor/Monlor-Test.git
git push origin master -f
}
reset() {
git checkout --orphan latest_branch
git add -A
git commit -am "`date +%Y-%m-%d`"
git branch -D master
git branch -m master
# git push -f origin master
# github
# coding
}
case $1 in
all)
localgit
github
coding
testing
;;
github)
localgit
github
;;
coding)
localgit
coding
;;
push)
localgit
github
coding
;;
pack)
pack $2 $3
;;
test)
localgit
testing
;;
reset)
reset
;;
esac