-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdotfiles
executable file
·87 lines (75 loc) · 2.12 KB
/
dotfiles
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
#!/usr/bin/env bash
# Top level manager for @CNG's system configuration scripts
# Script location determination accounting for symlinked script name
# http://stackoverflow.com/a/246128/172602
SOURCE="${BASH_SOURCE[0]}"
while [[ -h "$SOURCE" ]]; do # resolve $SOURCE until the file is no longer a symlink
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
done
APP_ROOT="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
source "$APP_ROOT/lib/common.bash"
hdlr_install () {
local force='false'
(( $# != 0 )) || module_install $force base
for module in "$@"; do
if [[ $module = --force ]]; then
force='true'
continue
fi
module_install $force "$module"
done
}
hdlr_upgrade () {
(( $# != 0 )) || module_upgrade --all
for module in "$@"; do
module_upgrade "$module"
done
}
hdlr_remove () {
(( $# != 0 )) || print_usage
local force='false'
for module in "$@"; do
shift # for detecting if --force is last
if [[ $module = --force ]]; then
(( $# != 0 )) || print_usage
force='true'
else
module_remove $force "$module"
fi
done
}
hdlr_list () {
module_list "$@"
}
hdlr_cleanup () {
(( $# == 0 )) || print_usage
packages_cleanup
}
hdlr_tests () {
(( $# == 0 )) || print_usage
source "$APP_ROOT/lib/tests.bash"
main_tests
}
err_report () {
echo "Error on line $1"
}
main () {
trap 'err_report $LINENO' ERR
cd "$( dirname "${BASH_SOURCE[0]}" )"
case ${1:-} in
install ) hdlr_install "${@:2}" ;;
reinstall ) hdlr_reinstall "${@:2}" ;;
upgrade ) hdlr_upgrade "${@:2}" ;;
remove ) hdlr_remove "${@:2}" ;;
cleanup ) hdlr_cleanup "${@:2}" ;;
list ) hdlr_list "${@:2}" ;;
tests ) hdlr_tests "${@:2}" ;;
help ) print_usage ;;
* ) print_usage; return 1 ;;
esac
trap - ERR
}
main "$@"
#TODO autocomplete http://askubuntu.com/questions/68175/how-to-create-script-with-auto-complete