summarylogtreecommitdiffstats
path: root/01-updater.patch
blob: 21f1203f5325d486b9d47192bf80c661683e3614 (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
--- updater.sh
+++ updater.sh
@@ -45 +45 @@
-PROFILE_PATH=false
+PROFILE_PATH='list'
@@ -87,2 +86,0 @@
-    -u           Update updater.sh and execute silently.  Do not seek confirmation.
-    -d           Do not look for updates to updater.sh.
@@ -102 +99,0 @@
-    -r           Only download user.js to a temporary file and open it.
@@ -112,6 +108,0 @@
-download_file() { # expects URL as argument ($1)
-  declare -r tf=$(mktemp)
-
-  $DOWNLOAD_METHOD "${tf}" "$1" &>/dev/null && echo "$tf" || echo '' # return the temp-filename or empty string on error
-}
-
@@ -180,36 +170,0 @@
-#   Update updater.sh   #
-#########################
-
-# Returns the version number of a updater.sh file
-get_updater_version() {
-  echo "$(sed -n '5 s/.*[[:blank:]]\([[:digit:]]*\.[[:digit:]]*\)/\1/p' "$1")"
-}
-
-# Update updater.sh
-# Default: Check for update, if available, ask user if they want to execute it
-# Args:
-#   -d: New version will not be looked for and update will not occur
-#   -u: Check for update, if available, execute without asking
-update_updater() {
-  [ "$UPDATE" = 'no' ] && return 0 # User signified not to check for updates
-
-  declare -r tmpfile="$(download_file 'https://raw.githubusercontent.com/arkenfox/user.js/master/updater.sh')"
-  [ -z "${tmpfile}" ] && echo -e "${RED}Error! Could not download updater.sh${NC}" && return 1 # check if download failed
-
-  if [[ $(get_updater_version "$SCRIPT_FILE") < $(get_updater_version "${tmpfile}") ]]; then
-    if [ "$UPDATE" = 'check' ]; then
-      echo -e "There is a newer version of updater.sh available. ${RED}Update and execute Y/N?${NC}"
-      read -p "" -n 1 -r
-      echo -e "\n\n"
-      [[ $REPLY =~ ^[Yy]$ ]] || return 0   # Update available, but user chooses not to update
-    fi
-  else
-    return 0   # No update available
-  fi
-  mv "${tmpfile}" "$SCRIPT_FILE"
-  chmod u+x "$SCRIPT_FILE"
-  "$SCRIPT_FILE" "$@" -d
-  exit 0
-}
-
-#########################
@@ -250,2 +205 @@
-  declare -r newfile="$(download_file 'https://raw.githubusercontent.com/arkenfox/user.js/master/user.js')"
-  [ -z "${newfile}" ] && echo -e "${RED}Error! Could not download user.js${NC}" && return 1 # check if download failed
+  declare -r newfile='@@USERJSDIR@@/user.js'
@@ -255 +209 @@
-    Available online: ${ORANGE}$(get_userjs_version "$newfile")${NC}
+    Package:          ${ORANGE}$(get_userjs_version "$newfile")${NC}
@@ -264 +217,0 @@
-      rm "$newfile"
@@ -281 +234 @@
-  mv "${newfile}" user.js
+  cp "${newfile}" user.js
@@ -331 +284 @@
-    while getopts ":hp:ludsno:bcvre" opt; do
+    while getopts ":hp:lsno:bcve" opt; do
@@ -342,6 +294,0 @@
-        u)
-          UPDATE='yes'
-          ;;
-        d)
-          UPDATE='no'
-          ;;
@@ -369,8 +315,0 @@
-        r)
-          tfile="$(download_file 'https://raw.githubusercontent.com/arkenfox/user.js/master/user.js')"
-          [ -z "${tfile}" ] && echo -e "${RED}Error! Could not download user.js${NC}" && exit 1 # check if download failed
-          mv "$tfile" "${tfile}.js"
-          echo -e "${ORANGE}Warning: user.js was saved to temporary file ${tfile}.js${NC}"
-          open_file "${tfile}.js"
-          exit 0
-          ;;
@@ -391 +329,0 @@
-update_updater "$@"