Skip to content
This repository was archived by the owner on Apr 29, 2022. It is now read-only.

Commit 68635af

Browse files
committed
release v2.0.0
1 parent db6df7e commit 68635af

File tree

2 files changed

+55
-61
lines changed

2 files changed

+55
-61
lines changed

auto-update.patch

Lines changed: 54 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,83 +1,77 @@
1-
From 5a2bb8d53450df35d23a115bc29c7959f0d42c0e Mon Sep 17 00:00:00 2001
2-
From: jomo <[email protected]>
3-
Date: Sun, 6 Dec 2015 21:38:22 +0100
4-
Subject: [PATCH] add auto-update.patch
5-
6-
---
7-
imgur-screenshot | 32 +++++++++++++++++++++++++++++++-
8-
1 file changed, 31 insertions(+), 1 deletion(-)
9-
101
diff --git a/imgur-screenshot b/imgur-screenshot
11-
index 81eacae..aa2ec17 100755
2+
index 4a9c8b9..a1347b6 100755
123
--- a/imgur-screenshot
134
+++ b/imgur-screenshot
14-
@@ -68,6 +68,7 @@ auto_delete=""
15-
copy_url="true"
16-
keep_file="true"
17-
check_update="true"
18-
+auto_update="false"
5+
@@ -82,6 +82,7 @@ load_default_config() {
6+
declare -g EDIT="false"
7+
declare -g AUTO_DELETE
8+
declare -g KEEP_FILE="true"
9+
+ declare -g AUTO_UPDATE="false"
1910

20-
# NOTICE: if you make changes here, also edit the docs at
21-
# https://github.com/jomo/imgur-screenshot/wiki/Config
22-
@@ -145,6 +146,13 @@ function check_for_update() {
23-
echo "Version ${remote_version} is available (You have ${current_version})"
24-
notify ok "Update found" "Version ${remote_version} is available (You have ${current_version}). https://github.com/jomo/imgur-screenshot"
11+
# NOTICE: if you make changes here, also edit the docs at
12+
# https://github.com/jomo/imgur-screenshot/wiki/Config
13+
@@ -119,7 +120,7 @@ parse_args() {
14+
echo " -k, --keep-file <true|false> Override 'KEEP_FILE' config"
15+
echo " -d, --auto-delete <s> Automatically delete image after <s> seconds"
16+
echo ""
17+
- echo " -u, --update Check for updates, exit"
18+
+ echo " -u, --update Check for a newer version, install if available, exit"
19+
echo ""
20+
echo " file Upload file instead of taking a screenshot"
21+
exit 0;;
22+
@@ -165,6 +166,7 @@ parse_args() {
23+
AUTO_DELETE="${2}"
24+
shift 2;;
25+
-u | --update)
26+
+ AUTO_UPDATE="true"
27+
check_for_update
28+
exit 0;;
29+
*)
30+
@@ -287,6 +289,13 @@ check_for_update() {
31+
echo "Version ${remote_version} is available (You have ${CURRENT_VERSION})"
32+
notify ok "Update found" "Version ${remote_version} is available (You have ${CURRENT_VERSION}). https://github.com/jomo/imgur-screenshot"
2533
echo "Check https://github.com/jomo/imgur-screenshot/releases/${remote_version} for more info."
2634
+
27-
+ if [ "${auto_update}" == "true" ]; then
28-
+ run_update
35+
+ if [ "${AUTO_UPDATE}" == "true" ]; then
36+
+ run_update "${remote_version}"
2937
+ else
3038
+ echo "Use --update to install the new version"
3139
+ fi
3240
+
33-
elif [ -z "${current_version}" ] || [ -z "${remote_version}" ]; then
41+
elif [ -z "${CURRENT_VERSION}" ] || [ -z "${remote_version}" ]; then
3442
echo "Invalid empty version string"
35-
echo "Current (local) version: '${current_version}'"
36-
@@ -157,6 +165,27 @@ function check_for_update() {
43+
echo "Current (local) version: '${CURRENT_VERSION}'"
44+
@@ -299,6 +308,33 @@ check_for_update() {
3745
fi
3846
}
3947

40-
+function run_update() {
41-
+ set -e
42-
+ local remote_script="https://github.com/jomo/imgur-screenshot/releases/download/${remote_version}/imgur-screenshot"
43-
+ local that
44-
+ local this_script
45-
+ local tmp_script
48+
+run_update() {
49+
+ local remote_version remote_script self script_path tmp_script bak_script
50+
+
51+
+ set -o errexit
4652
+
53+
+ remote_version="${1}"
54+
+ remote_script="https://github.com/jomo/imgur-screenshot/releases/download/${remote_version}/imgur-screenshot"
4755
+ tmp_script="$(mktemp)"
56+
+ bak_script="$(mktemp)"
4857
+
49-
+ # determine the script's location
50-
+ that="$(which "$0")"
51-
+ this_script="$(readlink "$that" || echo "$that")"
58+
+ # determine this script's location
59+
+ self="$(command -v "${0}")"
60+
+ script_path="$(readlink "${self}" || echo "${self}")"
5261
+
5362
+ # Download latest version
5463
+ echo "Downloading and installing latest version..."
55-
+ curl --compressed -fL -'#' "${remote_script}" > "${tmp_script}"
56-
+ mv "${tmp_script}" "${this_script}"
64+
+ curl --compressed -fsSL --stderr - -'#' "${remote_script}" > "${tmp_script}"
65+
+ if [ ! "${?}" -eq "0" ]; then
66+
+ echo "Update failed:" >&2
67+
+ cat "${tmp_script}" >&2
68+
+ exit 1
69+
+ fi
70+
+ mv -v "${script_path}" "${bak_script}.bak"
71+
+ mv -v "${tmp_script}" "${script_path}"
5772
+ echo "Successfully updated to ${remote_version}."
5873
+}
5974
+
60-
+
61-
function check_oauth2_client_secrets() {
62-
if [ -z "${imgur_acct_key}" ] || [ -z "${imgur_secret}" ]; then
63-
echo "In order to upload to your account, register a new application at:"
64-
@@ -406,7 +435,7 @@ while [ ${#} != 0 ]; do
65-
echo " -A, --album-id <album_id> Override 'album_id' config"
66-
echo " -k, --keep-file <true|false> Override 'keep_file' config"
67-
echo " -d, --auto-delete <s> Automatically delete image after <s> seconds"
68-
- echo " -u, --update Check for updates, exit"
69-
+ echo " -u, --update Check for a newer version, install if available, exit"
70-
echo " file Upload file instead of taking a screenshot"
71-
exit 0;;
72-
-v | --version)
73-
@@ -447,6 +476,7 @@ while [ ${#} != 0 ]; do
74-
auto_delete="${2}"
75-
shift 2;;
76-
-u | --update)
77-
+ auto_update="true"
78-
check_for_update
79-
exit 0;;
80-
*)
81-
--
82-
2.6.1
83-
75+
check_oauth2_client_secrets() {
76+
if [ -z "${CLIENT_ID}" ] || [ -z "${CLIENT_SECRET}" ]; then
77+
echo "Your CLIENT_ID and CLIENT_SECRET are not set."

imgur-screenshot

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# https://imgur.com/tools
44

55
initialize() {
6-
declare -g -r CURRENT_VERSION="v1.7.4"
6+
declare -g -r CURRENT_VERSION="v2.0.0"
77

88
# https://freedesktop.org/wiki/Software/xdg-user-dirs/
99
declare -r CONFIG_HOME="${XDG_CONFIG_HOME:-$HOME/.config}"

0 commit comments

Comments
 (0)