summarylogtreecommitdiffstats
path: root/updater.patch
blob: d4445322066fe555e1d14e695f57766f597d72da (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
--- updater
+++ updater
@@ -119 +119 @@
-			while getopts ':abc:de:g:hilno:p:qrstuvy' opt; do
+			while getopts ':abc:de:g:hilno:p:qrtvy' opt; do
@@ -180,4 +179,0 @@
-					# TODO: remove '-s' in future version
-					s|u)
-						update='true'
-						;;
@@ -297 +292,0 @@
-	update='false'
@@ -316 +311 @@
-${color_usage}Usage: ${0} [-abdghilnruvy] [-c CONFIG] [-e VERSION] [-o OVERRIDE] [-p PROFILE]${no_color_stdout}
+${color_usage}Usage: ${0} [-abdghilnrvy] [-c CONFIG] [-e VERSION] [-o OVERRIDE] [-p PROFILE]${no_color_stdout}
@@ -355 +349,0 @@
-  -s          (Deprecated) This is an alias for -u .
@@ -358 +351,0 @@
-  -u          Check for updates of this updater and install if available.
@@ -531,50 +523,0 @@
-#    Update Updater     #
-#########################
-
-# Update this updater. Call this function with "$@" as argument.
-update_updater() {
-	# update check has not been activated
-	[ "${update}" = 'false' ] && return 0
-	readonly new_updater="${tmp_dir}/new_updater"
-	if ! download_file "${new_updater}" \
-			'https://notabug.org/TotallyLeGIT/PH-userjs-updater/raw/main/updater'
-	then
-		print_warn 'Download of new updater failed'
-		return 1
-	fi
-	chmod u+x "${new_updater}"
-	current_updater_version="$("${script_path}" -v | cut -d ' ' -f 2)"
-	new_updater_version="$("${new_updater}" -v | cut -d ' ' -f 2)"
-
-	# compare updater versions, if different
-	while [ "${current_updater_version}" != "${new_updater_version}" ]; do
-		difference="$((${new_updater_version%%.*}-${current_updater_version%%.*}))"
-		# newer version available
-		if [ "${difference}" -gt 0 ]; then
-			printv_info '0' 'updater' 'update available'
-			# apply update
-			if ! { cat "${new_updater}" > "${script_path}" ; } > /dev/null 2>&1; then
-				print_warn "No permission to write file: '${script_path}'"
-				return 1
-			fi
-			printv_info '1' 'changelog' \
-					'https://notabug.org/TotallyLeGIT/PH-userjs-updater/raw/main/CHANGELOG.md'
-			# update user.js with new version
-			"${script_path}" "${@}"
-			# exit with exit code from updater call above
-			exit "${?}"
-		# version number is equal (go to next number)
-		elif [ "${difference}" -eq 0 ]; then
-			current_updater_version="${current_updater_version#*.}"
-			new_updater_version="${new_updater_version#*.}"
-		# this should not be happening
-		else
-			print_warn 'Your updater version seems odd. Check updater homepage' \
-					'and/or update manually.'
-			return 2
-		fi
-	done
-	printv_info '0' 'updater' 'up to date'
-}
-
-#########################
@@ -854 +796,0 @@
-update_updater "${@}"