-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathup
executable file
·64 lines (50 loc) · 1.75 KB
/
up
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
#! /usr/bin/env zsh
###############################################################################
## > Entry point ##
## This is the main entry point of the updater project. ##
## It will find out what distro the system is running, and invoke the ##
## right updater to do the job. ##
###############################################################################
#>>> Now in technicolor:
autoload colors ; colors
# Find out the system's distro:
__DISTRO__=""
if hash lsb_release 2> /dev/null; then
__DISTRO__=$(lsb_release --id | sed -e "s,.*[ \t],,g")
else
__DISTRO__=$(grep -E "^ID=" /etc/os-release | sed "s,ID=,,g")
fi
# Be sure it's all lowercase:
__DISTRO__=$(print "$__DISTRO__" | tr '[:upper:]' '[:lower:]')
# cd to the script directory, or something really wrong may happen when using
# source:
EXEC_LOCATION=$(which $0)
DIR_LOCATION=""
# If it isn't a symlink, cd into its directory:
if [[ ! -L $EXEC_LOCATION ]]; then
DIR_LOCATION="$(dirname $EXEC_LOCATION)"
# If it's a symlink, find its destination and cd there:
else
DIR_LOCATION="$(ls -l $EXEC_LOCATION)"
DIR_LOCATION="$(print $DIR_LOCATION | awk '{print $11}')"
DIR_LOCATION="$(dirname $DIR_LOCATION)"
fi
cd $DIR_LOCATION
# Depending on the distro:
case $__DISTRO__ in
# Arch Linux:
arch|archarm) source ./lib/arch.zsource ;;
# Debian and derivates:
debian) source ./lib/debian.zsource ;;
# Unsupported distro:
*)
print -n "$fg[red]The following distro is not supported:$fg[default] "
print "$__DISTRO__"
exit 1
;;
esac
# Run the updater:
update_distro "Updater" $@
return $?
# Unset variables:
unset __DISTRO__ EXEC_LOCATION DIR_LOCATION