summaryrefslogtreecommitdiff
path: root/build.sh
blob: 939000de3b817d670b0db0e7f2a316774aa82f8b (plain)
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
#!/bin/sh

as_sudo(){
	SUDO=sudo 
	$@
	SUDO=""
}

config_dir="${XDG_CONFIG_HOME:-$HOME/.config}"
home_dir="${XDG_DATA_HOME:-$HOME}"

dotfiles_install() {
	[ -d $config_dir ] || mkdir -v $config_dir
	COPY ./src/dotfiles/*  "$config_dir"
	COPY ./src/dotfiles/zsh/zshrc "$home_dir"
	COPY ./src/dotfiles/Xresources "$home_dir"/.Xresources
}

scripts_install() {
	[ -d /usr/local/bin ] || sudo mkdir -v /usr/local/bin
	as_sudo COPY ./src/scripts/* /usr/local/bin/
}

archlinux_install() {
	as_sudo COPY ./src/distros/arch-linux/pacman.conf /etc
}

profile_install() {
	[ -d /etc/profile.d ] || { sudo mkdir /etc/profile.d && printf "/etc/profile.d directory created" ; }
	as_sudo COPY ./src/etc/profile.d/theion.sh /etc/profile.d || echo "Couldn't install to /etc/profile.d"
}

help() {
	 cat <<EOF
Usage $0:
	-d		Install dotfiles to .config
	-s		Install scripts to /usr/local/bin
	-ds		Install scripts and dotfiles

	--profile	Install profile files
	--archlinux	Install Arch linux specific files
	--fix-profile	make /etc/profile.d sourced
	--force		Overwrite the existing files
	--all		Install everything (except Arch linux specific files)
EOF
exit 2
}

[ $# = 0 ] && help 

for argument in $@;do
	if [ $argument = "--force" ];then
		COPY(){ $SUDO cp -r $@; }
		break
	fi
	COPY(){ $SUDO cp -nr $@; }
done

for argument in $@;do
	case "$argument" in
		"-d") dotfiles_install;;

		"-s")
			scripts_install;;

		"-ds")
			dotfiles_install
			scripts_install
			;;

		"--profile") 
			profile_install;;

		"--archlinux") 
			archlinux_install
			;;
				
		"--all") 
			dotfiles_install
			scripts_install
			profile_install
			;;

		"--force");;

		*) help ;;
	esac
done