-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstart.sh
executable file
·71 lines (62 loc) · 1.28 KB
/
start.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
#!/bin/bash
DEFAULT_TEAM="https://gitlab.com/groups/a-esc"
TEAM=(
$DEFAULT_TEAM
"https://github.com/asanotigaku"
)
check_url(){
echo -n "checking "$1"... " 1>&2
result=`curl $1 -w '%{http_code}\n' -s -o /dev/null`
if [ 200 != "${result}" ]; then
echo "error(${result})" 1>&2
echo "error"
else
echo "ok" 1>&2
echo "ok"
fi
}
get_repo(){
for i in "${TEAM[@]}"; do
result=`check_url $i/$1`
if [ $result == "ok" ]; then
echo $i/$1
return
fi
done
echo "error"
}
make_repo(){
if [ -d $1 ]; then
echo "ディレクトリ \"$1\" が存在します.処理を中断します."
exit -1
fi
mkdir $1
cd $1
git init
repo=$DEFAULT_TEAM"/"$1".git"
git remote add origin $repo
echo -n "$repoを作成してください.[Enter]"
read
git push -u origin master
}
# check connection
ping google.com -c 1 >> /dev/null
if [ $? != 0 ]; then
echo "インターネットに接続してください"
exit -1
fi
echo -n "ホルストの年度(西暦): "
read year
echo $year"年"
title="holst-$year"
repo_url=`get_repo $title`
if [ $repo_url == "error" ]; then
echo "gitリポジトリが見つかりませんでした."
read -p "gitリポジトリを新規に作成しますか? [Y/n]: " yn
case $yn in
[n] ) exit;;
esac
make_repo $title
else
git clone $repo_url
fi