-
Notifications
You must be signed in to change notification settings - Fork 0
/
konfig-repo.sh
executable file
·61 lines (41 loc) · 1.17 KB
/
konfig-repo.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
#!/bin/bash
KONFIG_GROUP=${KONFIG_GROUP:-"konfig"}
REPOS_PATH=${REPOS_PATH:-"/usr/local/konfigrepo"}
if [ -d "$REPOS_PATH" ]; then
for path in "$@" ; do
if [ -d "$path" ]; then
if [ "$path" == "." ]; then
path=$(pwd)
fi
dir_to_be_managed=${path%/} # remove trailing slash from arg
repo_name=${dir_to_be_managed##*/}
git init --bare --shared=group "$REPOS_PATH/$repo_name"
cd "$dir_to_be_managed"
echo "service=\"/etc/konfig/$repo_name\"" >> Konfigfile
git init
git add .
git commit -m 'Initial commit'
git remote add origin "$REPOS_PATH/$repo_name"
git config branch.master.remote origin
git config branch.master.merge refs/heads/master
git push origin master
mkdir -p /etc/konfig/$repo_name
cat << EOF > /etc/konfig/$repo_name/00_pull.sh
cd $dir_to_be_managed
git pull --rebase
EOF
cat << EOF > /etc/konfig/$repo_name/01_check_syntax.sh
true
EOF
cat << EOF > /etc/konfig/$repo_name/reload.sh
/etc/init.d/$repo_name reload
EOF
cat << EOF > /etc/konfig/$repo_name/restart.sh
/etc/init.d/$repo_name restart
EOF
chmod +x /etc/konfig/$repo_name/*.sh
fi
done
else
echo "Please create $REPOS_PATH with konfig-init.sh"
fi