| 
									
										
										
										
											2014-10-04 12:19:37 +04:00
										 |  |  | #!/usr/bin/env bash | 
					
						
							| 
									
										
										
										
											2014-10-04 12:33:23 +04:00
										 |  |  | # Copyright (c) 2012 fbt <fbt@fleshless.org> | 
					
						
							|  |  |  | # | 
					
						
							|  |  |  | # About: | 
					
						
							|  |  |  | # A simple upload script for ZFH (http://zerofiles.org) | 
					
						
							| 
									
										
										
										
											2014-10-04 12:19:37 +04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-01-17 16:44:04 +03:00
										 |  |  | _self="${0##*/}" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-10-13 13:52:26 +03:00
										 |  |  | # Defaults for XDG | 
					
						
							|  |  |  | if ! [[ "$XDG_RUNTIME_DIR" ]]; then | 
					
						
							|  |  |  | 	XDG_RUNTIME_DIR="/run/user/$UID" | 
					
						
							|  |  |  | fi | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-04 12:19:37 +04:00
										 |  |  | cfg_url_regex='^[A-Za-z]([A-Za-z0-9+.-]+)?://.+' | 
					
						
							| 
									
										
										
										
											2015-10-13 13:52:26 +03:00
										 |  |  | cfg_tmp_dir="$XDG_RUNTIME_DIR/sup"; TEMPDIR="$cfg_tmp_dir" | 
					
						
							| 
									
										
										
										
											2015-10-20 21:38:29 +03:00
										 |  |  | cfg_service_url='https://8fw.me' | 
					
						
							| 
									
										
										
										
											2014-10-04 12:19:37 +04:00
										 |  |  | cfg_screenshot_ext='png' | 
					
						
							| 
									
										
										
										
											2015-11-13 05:08:55 +03:00
										 |  |  | cfg_max_filesize='200M' | 
					
						
							| 
									
										
										
										
											2014-10-04 12:19:37 +04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-01-17 16:44:04 +03:00
										 |  |  | [[ -f $HOME/.suprc ]] && { source "$HOME/.suprc"; } | 
					
						
							| 
									
										
										
										
											2014-10-04 12:19:37 +04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-03-08 19:48:26 +03:00
										 |  |  | _cat() { | 
					
						
							|  |  |  | 	while read; do | 
					
						
							|  |  |  | 		printf '%s\n' "$REPLY" | 
					
						
							|  |  |  | 	done | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-10-13 13:52:26 +03:00
										 |  |  | is_url() { | 
					
						
							|  |  |  | 	[[ "$1" =~ $cfg_url_regex ]] | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-10 16:54:55 +03:00
										 |  |  | sup.msg() { printf '%s\n' "[sup] $1"; } | 
					
						
							| 
									
										
										
										
											2014-10-04 12:19:37 +04:00
										 |  |  | sup.err() { sup.msg "(error) $1" >&2; } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | sup.usage() { | 
					
						
							| 
									
										
										
										
											2015-03-08 19:48:26 +03:00
										 |  |  | 	_cat <<- EOF | 
					
						
							|  |  |  | 		Usage: ${_self} [-RsF] [-D num] [file/url]" | 
					
						
							|  |  |  | 		    Flags: | 
					
						
							|  |  |  | 		        -R                   # Remove the file after uploading. | 
					
						
							|  |  |  | 		        -s                   # Make a screenshot and upload it instead of a file. | 
					
						
							|  |  |  | 		        -F                   # Make a fullscreen shot instead of prompting for a window/area. Implies -s. | 
					
						
							| 
									
										
										
										
											2015-06-23 23:25:48 +03:00
										 |  |  | 		        -d                   # Supply a dexcription. | 
					
						
							| 
									
										
										
										
											2015-03-08 19:48:26 +03:00
										 |  |  | 		        -D <num>             # Delay the shot by <num> seconds. | 
					
						
							|  |  |  | 		        -p                   # Make the file private. Requires \$secret to be set in the config. | 
					
						
							| 
									
										
										
										
											2015-06-21 16:05:12 +03:00
										 |  |  | 		        -u                   # Generate a shortlink from URL. | 
					
						
							| 
									
										
										
										
											2015-11-13 05:08:55 +03:00
										 |  |  | 				  -m                   # Maximum filesize (in megabytes) | 
					
						
							| 
									
										
										
										
											2015-03-08 19:48:26 +03:00
										 |  |  | 		 | 
					
						
							|  |  |  | 		    Config options (~/.suprc): | 
					
						
							|  |  |  | 		        secret               # Your personal token. Get it at https://zfh.so/settings_form | 
					
						
							|  |  |  | 		        cfg_screenshot_ext   # Screenshot file type, used by scrot. | 
					
						
							| 
									
										
										
										
											2015-11-13 05:08:55 +03:00
										 |  |  | 				  cfg_max_filesize     # Maximum filesize in megabytes. | 
					
						
							| 
									
										
										
										
											2015-03-08 19:48:26 +03:00
										 |  |  | 		        # Others are self-explanatory: | 
					
						
							|  |  |  | 		        cfg_url_regex | 
					
						
							|  |  |  | 		        cfg_tmp_dir | 
					
						
							| 
									
										
										
										
											2015-06-21 09:52:29 +03:00
										 |  |  | 		        cfg_service_url | 
					
						
							| 
									
										
										
										
											2015-03-08 19:48:26 +03:00
										 |  |  | 	EOF | 
					
						
							| 
									
										
										
										
											2014-10-04 12:19:37 +04:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | sup.env() { | 
					
						
							|  |  |  | 	for i in "$cfg_tmp_dir"; do | 
					
						
							|  |  |  | 		[[ -d "$i" ]] || { mkdir -p "$i"; } | 
					
						
							|  |  |  | 	done | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-21 09:52:29 +03:00
										 |  |  | sup.get_hash() { | 
					
						
							|  |  |  | 	read file_hash _ < <( sha1sum "$1" ) | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-13 05:08:55 +03:00
										 |  |  | sup.get_max_filesize() { | 
					
						
							|  |  |  | 	if [[ $cfg_max_filesize =~ ^[0-9]+[BKMG]?$ ]]; then | 
					
						
							|  |  |  | 		max_filesize_base="${cfg_max_filesize//[BKMG]/}" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		case "$cfg_max_filesize" in | 
					
						
							|  |  |  | 			*K) max_filesize_bytes=$(( max_filesize_base * 1024 ));; | 
					
						
							|  |  |  | 			*M) max_filesize_bytes=$(( max_filesize_base * 1024 * 1024 ));; | 
					
						
							|  |  |  | 			*G) max_filesize_bytes=$(( max_filesize_base * 1024 * 1024 * 1024 ));; | 
					
						
							|  |  |  | 			*) max_filesize_bytes=$max_filesize_base;; | 
					
						
							|  |  |  | 		esac | 
					
						
							|  |  |  | 	else | 
					
						
							|  |  |  | 		sup.err "Wrong cfg_max_filesize: $cfg_max_filesize" | 
					
						
							|  |  |  | 		return 1 | 
					
						
							|  |  |  | 	fi | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-04 12:19:37 +04:00
										 |  |  | sup.upload() { | 
					
						
							| 
									
										
										
										
											2015-06-21 16:05:12 +03:00
										 |  |  | 	if (( flag_scrot )); then | 
					
						
							| 
									
										
										
										
											2015-10-13 13:57:56 +03:00
										 |  |  | 		flag_rm=1 | 
					
						
							| 
									
										
										
										
											2015-06-21 16:05:12 +03:00
										 |  |  | 		file=$(sup.scrot) || { return 1; } | 
					
						
							|  |  |  | 	else | 
					
						
							|  |  |  | 		(( $# )) || { | 
					
						
							|  |  |  | 			sup.usage | 
					
						
							|  |  |  | 			return 1 | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		target="$1" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-10-13 13:52:26 +03:00
										 |  |  | 		if is_url "$target"; then | 
					
						
							| 
									
										
										
										
											2015-10-13 13:57:56 +03:00
										 |  |  | 			flag_rm=1 | 
					
						
							| 
									
										
										
										
											2015-06-21 16:05:12 +03:00
										 |  |  | 			file=$(sup.mktemp "$cfg_tmp_dir") | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-13 05:08:55 +03:00
										 |  |  | 			sup.get_max_filesize || { return 1; } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			curl --max-filesize "$max_filesize_bytes" -skL "$target" > "$file" | 
					
						
							|  |  |  | 			curl_result=$? | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			if (( curl_result )); then | 
					
						
							|  |  |  | 				case "$curl_result" in | 
					
						
							|  |  |  | 					63) sup.err "File exceeds cfg_max_filesize";; | 
					
						
							|  |  |  | 					*) sup.err "Could not download file.";; | 
					
						
							|  |  |  | 				esac | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-21 16:05:12 +03:00
										 |  |  | 				return 1 | 
					
						
							| 
									
										
										
										
											2015-11-13 05:08:55 +03:00
										 |  |  | 			fi | 
					
						
							| 
									
										
										
										
											2015-06-21 16:05:12 +03:00
										 |  |  | 		else | 
					
						
							|  |  |  | 			file="$target" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			[[ -f "$file" ]] || { | 
					
						
							|  |  |  | 				sup.err "No such file: ${file}" | 
					
						
							|  |  |  | 				return 1 | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		fi | 
					
						
							|  |  |  | 	fi | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-21 09:52:29 +03:00
										 |  |  | 	sup.get_hash "$file" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-22 03:13:44 +03:00
										 |  |  | 	file_url=$( curl -fsL "${cfg_service_url}/api?mode=file&file=${file_hash}&direct=1&short=${flag_shortlink}" ) | 
					
						
							| 
									
										
										
										
											2015-06-22 02:44:11 +03:00
										 |  |  | 	if ! (( $? )); then | 
					
						
							|  |  |  | 		printf '%s\n' "$file_url" | 
					
						
							| 
									
										
										
										
											2015-06-21 09:52:29 +03:00
										 |  |  | 	else | 
					
						
							| 
									
										
										
										
											2015-07-05 17:14:27 +03:00
										 |  |  | 		curl -sL \ | 
					
						
							| 
									
										
										
										
											2015-06-21 09:52:29 +03:00
										 |  |  | 			-F file="@$file" \ | 
					
						
							|  |  |  | 			-F upload_mode='api' \ | 
					
						
							|  |  |  | 			-F flag_private="$flag_private" \ | 
					
						
							| 
									
										
										
										
											2015-06-22 03:13:44 +03:00
										 |  |  | 			-F short="$flag_shortlink" \ | 
					
						
							| 
									
										
										
										
											2015-06-23 23:25:48 +03:00
										 |  |  | 			-F description="$description" \ | 
					
						
							| 
									
										
										
										
											2015-06-21 09:52:29 +03:00
										 |  |  | 			-F secret="$secret" \ | 
					
						
							|  |  |  | 			-F submit="" \ | 
					
						
							|  |  |  | 			-A 'zerofiles.org upload script' \ | 
					
						
							|  |  |  | 			"$cfg_service_url/upload" | 
					
						
							| 
									
										
										
										
											2015-07-05 17:14:27 +03:00
										 |  |  | 	fi | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (( $? )); then | 
					
						
							|  |  |  | 		sup.err 'Something has gone wrong with the upload.' | 
					
						
							|  |  |  | 		return 7 | 
					
						
							|  |  |  | 	else | 
					
						
							|  |  |  | 		if (( flag_rm )); then | 
					
						
							|  |  |  | 			sup.msg "Removing file: $file" | 
					
						
							|  |  |  | 			rm "$file" | 
					
						
							| 
									
										
										
										
											2015-06-21 16:05:12 +03:00
										 |  |  | 		fi | 
					
						
							|  |  |  | 	fi | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | sup.url() { | 
					
						
							|  |  |  | 	declare url=$1 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if ! curl -fsL "$cfg_service_url/api?mode=url_add&url=${url}&raw=1"; then | 
					
						
							|  |  |  | 		sup.err 'Something went wrong!' | 
					
						
							| 
									
										
										
										
											2015-06-21 09:52:29 +03:00
										 |  |  | 	fi | 
					
						
							| 
									
										
										
										
											2014-10-04 12:19:37 +04:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | sup.mktemp() { | 
					
						
							|  |  |  | 	>"$1" || { | 
					
						
							|  |  |  | 		sup.err "Cannot create $1!" | 
					
						
							|  |  |  | 		return 1 | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-10 16:54:55 +03:00
										 |  |  | 	printf '%s\n' "$1" | 
					
						
							| 
									
										
										
										
											2014-10-04 12:19:37 +04:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | sup.scrot() { | 
					
						
							| 
									
										
										
										
											2015-02-10 16:51:20 +03:00
										 |  |  | 	declare tmp_file | 
					
						
							| 
									
										
										
										
											2014-10-04 12:19:37 +04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-01-17 16:44:04 +03:00
										 |  |  | 	[[ "$scrot_exec" ]] || { scrot_exec=$(type -P scrot); } | 
					
						
							| 
									
										
										
										
											2014-10-04 12:19:37 +04:00
										 |  |  | 	[[ "$scrot_exec" ]] || { | 
					
						
							|  |  |  | 		sup.err "Please install scrot to use this function" | 
					
						
							|  |  |  | 		return 1 | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-10 16:45:15 +03:00
										 |  |  | 	(( "$flag_scrot_fullscreen" )) || { scrot_args+=( '-s' ); } | 
					
						
							| 
									
										
										
										
											2014-10-04 12:19:37 +04:00
										 |  |  | 	[[ "$cfg_scrot_delay" ]] && { scrot_args+=( "-d $cfg_scrot_delay" ); } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-04 12:50:49 +04:00
										 |  |  | 	tmp_file="$(sup.mktemp "${cfg_tmp_dir}" ".${cfg_screenshot_ext}")" | 
					
						
							| 
									
										
										
										
											2014-10-04 12:19:37 +04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-04 12:50:49 +04:00
										 |  |  | 	scrot "${scrot_args[@]}" "$tmp_file" || { | 
					
						
							| 
									
										
										
										
											2014-10-04 12:19:37 +04:00
										 |  |  | 		sup.err "Failed to take a screenshot." | 
					
						
							|  |  |  | 		return 1 | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-10 16:54:55 +03:00
										 |  |  | 	printf '%s\n' "$tmp_file" | 
					
						
							| 
									
										
										
										
											2014-10-04 12:19:37 +04:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-04 12:45:31 +04:00
										 |  |  | sup.mktemp() { | 
					
						
							| 
									
										
										
										
											2015-02-10 16:51:20 +03:00
										 |  |  | 	declare tmp_file_name tmp_file_name_extra="$2" tmp_dir="$1"  | 
					
						
							| 
									
										
										
										
											2014-10-04 12:45:31 +04:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	[[ -d "$tmp_dir" ]] || { | 
					
						
							|  |  |  | 		sup.err "${tmp_dir} does not exist or is not a directory." | 
					
						
							|  |  |  | 		return 1 | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	until [[ ! -e "${tmp_dir}/${tmp_file_name}" ]]; do | 
					
						
							|  |  |  | 		tmp_file_name="${RANDOM}${RANDOM}${tmp_file_name_extra}" | 
					
						
							|  |  |  | 	done | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-10 16:54:55 +03:00
										 |  |  | 	printf '%s\n' "${tmp_dir}/${tmp_file_name}" | 
					
						
							| 
									
										
										
										
											2014-10-04 12:45:31 +04:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-10-12 17:59:33 +03:00
										 |  |  | sup.get_my_ip() { | 
					
						
							|  |  |  | 	my_ip=$( curl -fsL https://zfh.so/ip ) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if ! (( $? )); then | 
					
						
							|  |  |  | 		printf '%s\n' $my_ip | 
					
						
							|  |  |  | 	fi | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-20 11:23:26 +03:00
										 |  |  | sup.set_argv() { | 
					
						
							|  |  |  | 	declare arg opt c | 
					
						
							|  |  |  | 	declare -g argv | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-01 17:33:10 +03:00
										 |  |  | 	while (( $# )); do | 
					
						
							| 
									
										
										
										
											2015-02-20 11:23:26 +03:00
										 |  |  | 		unset -v arg opt c | 
					
						
							| 
									
										
										
										
											2015-02-01 17:33:10 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		case "$1" in | 
					
						
							| 
									
										
										
										
											2015-02-20 11:23:26 +03:00
										 |  |  | 			(--) argv+=( "$1" ); break;; | 
					
						
							| 
									
										
										
										
											2015-02-01 17:33:10 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 			(--*) | 
					
						
							|  |  |  | 				IFS='=' read arg opt <<< "$1" | 
					
						
							| 
									
										
										
										
											2015-02-20 11:23:26 +03:00
										 |  |  | 				argv+=( "$arg" ) | 
					
						
							| 
									
										
										
										
											2015-02-01 17:33:10 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 				[[ "$opt" ]] && { | 
					
						
							| 
									
										
										
										
											2015-02-20 11:23:26 +03:00
										 |  |  | 					argv+=( "$opt" ) | 
					
						
							| 
									
										
										
										
											2015-02-01 17:33:10 +03:00
										 |  |  | 				} | 
					
						
							| 
									
										
										
										
											2014-10-04 13:17:06 +04:00
										 |  |  | 			;; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-01 17:33:10 +03:00
										 |  |  | 			(-*) | 
					
						
							|  |  |  | 				while read -n1 c | 
					
						
							|  |  |  | 				do | 
					
						
							|  |  |  | 					case "$c" in | 
					
						
							|  |  |  | 						-|'') :;; | 
					
						
							| 
									
										
										
										
											2015-02-20 11:23:26 +03:00
										 |  |  | 						*) argv+=( "-$c" );; | 
					
						
							| 
									
										
										
										
											2015-02-01 17:33:10 +03:00
										 |  |  | 					esac | 
					
						
							|  |  |  | 				done <<< "$1" | 
					
						
							|  |  |  | 			;; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-20 11:23:26 +03:00
										 |  |  | 			(*) argv+=( "$1" );; | 
					
						
							| 
									
										
										
										
											2014-10-04 13:17:06 +04:00
										 |  |  | 		esac | 
					
						
							| 
									
										
										
										
											2015-02-01 17:33:10 +03:00
										 |  |  | 		shift | 
					
						
							| 
									
										
										
										
											2014-10-04 13:17:06 +04:00
										 |  |  | 	done | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-04 12:19:37 +04:00
										 |  |  | main() { | 
					
						
							| 
									
										
										
										
											2015-02-10 16:45:15 +03:00
										 |  |  | 	declare args file target flag_private flag_rm flag_scrot flag_scrot_fullscreen cfg_scrot_delay | 
					
						
							| 
									
										
										
										
											2015-06-22 03:13:44 +03:00
										 |  |  | 	declare flag_shortlink=0 | 
					
						
							| 
									
										
										
										
											2014-10-04 13:17:06 +04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-04 12:19:37 +04:00
										 |  |  | 	while [[ "$1" ]]; do | 
					
						
							|  |  |  | 		case "$1" in | 
					
						
							|  |  |  | 			-p|--private) flag_private='true';; | 
					
						
							|  |  |  | 			-R|--remove-file) flag_rm='1';; | 
					
						
							|  |  |  | 			 | 
					
						
							|  |  |  | 			-s|--screenshot) flag_scrot='1';; | 
					
						
							| 
									
										
										
										
											2015-06-23 23:25:48 +03:00
										 |  |  | 			-d|--description) description="$2"; shift;; | 
					
						
							| 
									
										
										
										
											2014-10-04 12:19:37 +04:00
										 |  |  | 			-D|--screenshot-delay) cfg_scrot_delay="$2"; shift;; | 
					
						
							| 
									
										
										
										
											2015-03-08 19:48:26 +03:00
										 |  |  | 			-F|--fullscreen) | 
					
						
							|  |  |  | 				flag_scrot='1' | 
					
						
							|  |  |  | 				flag_scrot_fullscreen='1' | 
					
						
							|  |  |  | 			;; | 
					
						
							| 
									
										
										
										
											2015-06-21 16:05:12 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-10-12 17:59:33 +03:00
										 |  |  | 			-i|--my-ip) action='getmyip';; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-22 03:13:44 +03:00
										 |  |  | 			-S|--short) flag_shortlink='1';; | 
					
						
							| 
									
										
										
										
											2015-06-21 16:05:12 +03:00
										 |  |  | 			-u|--url) action='url';; | 
					
						
							| 
									
										
										
										
											2014-10-04 12:33:23 +04:00
										 |  |  | 			 | 
					
						
							| 
									
										
										
										
											2014-10-04 12:19:37 +04:00
										 |  |  | 			-h|--help|--usage) sup.usage; return;; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-10 16:45:15 +03:00
										 |  |  | 			--) shift; break;; | 
					
						
							| 
									
										
										
										
											2014-10-04 12:19:37 +04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-10 16:45:15 +03:00
										 |  |  | 			*) break;; | 
					
						
							| 
									
										
										
										
											2014-10-04 12:19:37 +04:00
										 |  |  | 		esac | 
					
						
							|  |  |  | 		shift | 
					
						
							|  |  |  | 	done | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	sup.env | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-21 16:05:12 +03:00
										 |  |  | 	case "${action:-upload}" in | 
					
						
							| 
									
										
										
										
											2015-06-22 02:29:57 +03:00
										 |  |  | 		upload) sup.upload "$1";; | 
					
						
							| 
									
										
										
										
											2015-06-21 16:05:12 +03:00
										 |  |  | 		url) sup.url "$1";; | 
					
						
							| 
									
										
										
										
											2015-10-12 17:59:33 +03:00
										 |  |  | 		getmyip) sup.get_my_ip;; | 
					
						
							| 
									
										
										
										
											2015-06-21 16:05:12 +03:00
										 |  |  | 	esac | 
					
						
							| 
									
										
										
										
											2014-10-04 12:19:37 +04:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-20 11:23:26 +03:00
										 |  |  | sup.set_argv "$@" | 
					
						
							|  |  |  | main "${argv[@]}" |