-
Notifications
You must be signed in to change notification settings - Fork 4
/
cmrepo.sh
56 lines (52 loc) · 2.33 KB
/
cmrepo.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
#!/bin/bash
#################################################################################
# Title: Cloudbox: Community Repo Cloner #
# Author(s): Desimaniac (Original creator) & Migz93 (Community edition) #
# URL: https://github.com/Cloudbox/Community #
# Description: Clones Community repo. #
# -- #
# Part of the Cloudbox project: https://cloudbox.works #
#################################################################################
# GNU General Public License v3.0 #
#################################################################################
# Usage: #
# ====== #
# curl -s https://cloudbox.works/scripts/cmrepo.sh | bash #
# wget -qO- https://cloudbox.works/scripts/cmrepo.sh | bash #
#################################################################################
## Variables
COMMUNITY_PATH="$HOME/community"
COMMUNITY_REPO="https://github.com/Cloudbox/Community.git"
## Clone Community and pull latest commit
if [ -d "$COMMUNITY_PATH" ]; then
if [ -d "$COMMUNITY_PATH/.git" ]; then
cd "$COMMUNITY_PATH"
git clean -df
git pull
git reset --hard origin/$(git rev-parse --abbrev-ref HEAD)
git submodule update --init --recursive
else
cd "$COMMUNITY_PATH"
git init
git remote add origin "$COMMUNITY_REPO"
git fetch
git branch master origin/master
git checkout -f master
git clean -df
git pull
git reset --hard origin/master
git submodule update --init --recursive
fi
else
git clone "$COMMUNITY_REPO" "$COMMUNITY_PATH"
cd "$COMMUNITY_PATH"
git submodule update --init --recursive
fi
## Copy settings and config files into Community folder
shopt -s nullglob
for i in "$COMMUNITY_PATH"/defaults/*.default; do
if [ ! -f "$COMMUNITY_PATH/$(basename "${i%.*}")" ]; then
cp -n "${i}" "$COMMUNITY_PATH/$(basename "${i%.*}")"
fi
done
shopt -u nullglob