-
Notifications
You must be signed in to change notification settings - Fork 4
/
repo.sh
71 lines (66 loc) · 2.95 KB
/
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
62
63
64
65
66
67
68
69
70
71
#!/bin/bash
#################################################################################
# Title: Cloudbox: Cloudbox Repo Cloner #
# Author(s): Desimaniac #
# URL: https://github.com/Cloudbox/Cloudbox #
# Description: Clones Cloudbox repo. #
# -- #
# Part of the Cloudbox project: https://cloudbox.works #
#################################################################################
# GNU General Public License v3.0 #
#################################################################################
# Usage: #
# ====== #
# curl -s https://cloudbox.works/repo.sh | bash #
# wget -qO- https://cloudbox.works/repo.sh | bash #
#################################################################################
## Variables
CLOUDBOX_PATH="$HOME/cloudbox"
CLOUDBOX_REPO="https://github.com/Cloudbox/Cloudbox.git"
## Clone Cloudbox and pull latest commit
if [ -d "$CLOUDBOX_PATH" ]; then
if [ -d "$CLOUDBOX_PATH/.git" ]; then
cd "$CLOUDBOX_PATH"
git fetch --all --prune
git checkout master
git reset --hard origin/master
git submodule update --init --recursive
else
cd "$CLOUDBOX_PATH"
rm -rf library/
git init
git remote add origin "$CLOUDBOX_REPO"
git fetch --all --prune
git branch master origin/master
git reset --hard origin/master
git submodule update --init --recursive
fi
else
git clone "$CLOUDBOX_REPO" "$CLOUDBOX_PATH"
cd "$CLOUDBOX_PATH"
git submodule update --init --recursive
fi
## Copy settings and config files into Cloudbox folder
shopt -s nullglob
for i in "$CLOUDBOX_PATH"/defaults/*.default; do
if [ ! -f "$CLOUDBOX_PATH/$(basename "${i%.*}")" ]; then
cp -n "${i}" "$CLOUDBOX_PATH/$(basename "${i%.*}")"
fi
done
shopt -u nullglob
## Set nano as default editor
export EDITOR=nano
if [[ "$SHELL" == *"bash"* ]]; then
if [ -f $HOME/.bashrc ]; then
sed -i '/^[ \t]*export EDITOR=/{h;s/=.*/=nano/};${x;/^$/{s//export EDITOR=nano/;H};x}' $HOME/.bashrc
elif [ -f /etc/skel/.bashrc ]; then
cp /etc/skel/.bashrc $HOME/.bashrc
chown $USERNAME:$USERNAME $HOME/.bashrc
chmod 644 $HOME/.bashrc
sed -i '/^[ \t]*export EDITOR=/{h;s/=.*/=nano/};${x;/^$/{s//export EDITOR=nano/;H};x}' $HOME/.bashrc
fi
elif [[ "$SHELL" == *"zsh"* ]]; then
if [ -f $HOME/.zshrc ]; then
sed -i '/^[ \t]*export EDITOR=/{h;s/=.*/=nano/};${x;/^$/{s//export EDITOR=nano/;H};x}' $HOME/.zshrc
fi
fi