forked from mietek/bashmenot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
src.sh
60 lines (47 loc) · 1.37 KB
/
src.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
unset POSIXLY_CORRECT
set -o pipefail
export BASHMENOT_DIR
BASHMENOT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd -P )
source "${BASHMENOT_DIR}/src/date.sh"
source "${BASHMENOT_DIR}/src/sort.sh"
source "${BASHMENOT_DIR}/src/log.sh"
source "${BASHMENOT_DIR}/src/expect.sh"
source "${BASHMENOT_DIR}/src/platform.sh"
source "${BASHMENOT_DIR}/src/line.sh"
source "${BASHMENOT_DIR}/src/file.sh"
source "${BASHMENOT_DIR}/src/package.sh"
source "${BASHMENOT_DIR}/src/hash.sh"
source "${BASHMENOT_DIR}/src/tar.sh"
source "${BASHMENOT_DIR}/src/git.sh"
source "${BASHMENOT_DIR}/src/curl.sh"
source "${BASHMENOT_DIR}/src/s3.sh"
bashmenot_self_update () {
if (( ${BASHMENOT_NO_SELF_UPDATE:-0} )) ||
[[ ! -d "${BASHMENOT_DIR}/.git" ]]
then
return 0
fi
local now candidate_time
now=$( get_current_time )
if candidate_time=$( get_modification_time "${BASHMENOT_DIR}" ) &&
(( candidate_time + 60 >= now ))
then
return 0
fi
local url
url="${BASHMENOT_URL:-https://github.com/mietek/bashmenot}"
log_begin 'Self-updating bashmenot...'
local commit_hash
if ! commit_hash=$( git_update_into "${url}" "${BASHMENOT_DIR}" ); then
log_end 'error'
return 0
fi
log_end "done, ${commit_hash}"
touch "${BASHMENOT_DIR}" || return 1
BASHMENOT_NO_SELF_UPDATE=1 \
source "${BASHMENOT_DIR}/src.sh"
}
if ! bashmenot_self_update; then
log_error 'Failed to self-update bashmenot'
exit 1
fi