Merge branch 'main' into documentation

This commit is contained in:
TheOnePath 2021-06-04 19:23:01 +01:00
commit 27c75b3c9b
5 changed files with 1827 additions and 33 deletions

View File

@ -6,20 +6,21 @@ Currently this program can only update the Beta release of Microsoft Edge for am
## Usage
```
Usage: updater [OPTION]
Microsoft Edge Updater (0.1.2) - An updater program which can install the latest available version of Microsoft Edge to non-Debian-based Linux distros.
Microsoft Edge Updater (0.1.3) - An updater program which can install the latest available version of Microsoft Edge to non-Debian-based Linux distros.
DISCLAIMER: Currently this program can only update the Beta release of Microsoft Edge for amd64 architectures.
Options:
-nn, --no-notify Prevent notifications from being set after a session.
-y, --yes-all Assume yes to all yes/no decisions.
-v, --version Print out the version of the script and exit.
--help Print this help message and exit
-h, --help Print this help message and exit
```
## Information
* Program Name - Microsoft Edge Updater
* Script Name - updater
* Version - 0.1.2 (Beta)
* Version - 0.1.3 (Beta)
* Synopsis - update Microsoft Edge (Beta) to the latest release.
* Author(s) - Ethan Smith-Coss (No contact)
* License - No License
* License - GNU GPLv3+

1690
logs/updater.history Normal file

File diff suppressed because it is too large Load Diff

63
logs/updater.log Normal file
View File

@ -0,0 +1,63 @@
2021-05-28T15:09:46+01:00 (PREINIT): ----[New instance of script has been started: 2021-05-28T15:09:46+01:00]----
2021-05-28T15:09:46+01:00 (DEBUG): The yes flag has been set to: 1.
2021-05-28T15:09:46+01:00 (DEBUG): Microsoft Edge (Beta) is installed to system. Proceeding with update...
2021-05-28T15:09:46+01:00 (DEBUG): Checking for a source.list in current runtime directory...
2021-05-28T15:09:46+01:00 (DEBUG): Found a souce.list in /home/ethan/.local/bin/Microsoft-Edge-Updater.
2021-05-28T15:09:46+01:00 (DEBUG): Checking if host is available according to defined value of [host]: https://packages.microsoft.com...
2021-05-28T15:09:46+01:00 (DEBUG): Host is known and reachable. Continuing update to fetch data...
2021-05-28T15:09:46+01:00 (DEBUG): Fetching Packages file from https://packages.microsoft.com/repos/edge/dists/stable/main for amd64 architectures...
--2021-05-28 15:09:46-- https://packages.microsoft.com/repos/edge/dists/stable/main/binary-amd64/Packages.gz
Resolving packages.microsoft.com... 13.80.99.124
Connecting to packages.microsoft.com|13.80.99.124|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 4798 (4.7K) [application/octet-stream]
Saving to: /tmp/microsoft-edge-autoupdater/Packages.gz
0K .... 100% 978M=0s
2021-05-28 15:09:46 (978 MB/s) - /tmp/microsoft-edge-autoupdater/Packages.gz saved [4798/4798]
2021-05-28T15:09:46+01:00 (DEBUG): Successfully downloaded release package information.
2021-05-28T15:09:46+01:00 (DEBUG): Fetching Contents-amd64.gz from https://packages.microsoft.com/repos/edge/dists/stable/
--2021-05-28 15:09:46-- https://packages.microsoft.com/repos/edge/dists/stable//Contents-amd64.gz
Resolving packages.microsoft.com... 13.80.99.124
Connecting to packages.microsoft.com|13.80.99.124|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1521 (1.5K) [application/octet-stream]
Saving to: /tmp/microsoft-edge-autoupdater/Contents-amd64.gz
0K . 100% 522M=0s
2021-05-28 15:09:46 (522 MB/s) - /tmp/microsoft-edge-autoupdater/Contents-amd64.gz saved [1521/1521]
2021-05-28T15:09:46+01:00 (DEBUG): Successfully downloaded release contents information.
2021-05-28T15:09:46+01:00 (DEBUG): Uncompressing downloaded gz file using gunzip, /tmp/microsoft-edge-autoupdater/Packages.gz...
2021-05-28T15:09:46+01:00 (DEBUG): Successfully uncompressed content.
2021-05-28T15:09:46+01:00 (DEBUG): Identifying the most recent package information from Packages catelogue...
2021-05-28T15:09:46+01:00 (DEBUG): Extrapolated most recent package information entry from /tmp/microsoft-edge-autoupdater/Release. Package information selected is as below:
(Release Info) Package: microsoft-edge-beta
(Release Info) Priority: optional
(Release Info) Section: web
(Release Info) Installed-Size: 326085
(Release Info) Maintainer: Microsoft Edge for Linux Team <null@null.com>
(Release Info) Architecture: amd64
(Release Info) Version: 91.0.864.37-1
(Release Info) Provides: www-browser
(Release Info) Depends: ca-certificates, fonts-liberation, libasound2 (>= 1.0.16), libatk-bridge2.0-0 (>= 2.5.3), libatk1.0-0 (>= 2.2.0), libatomic1 (>= 4.8), libatspi2.0-0 (>= 2.9.90), libc6 (>= 2.17), libcairo2 (>= 1.6.0), libcups2 (>= 1.4.0), libcurl3-gnutls | libcurl3-nss | libcurl4 | libcurl3, libdbus-1-3 (>= 1.5.12), libdrm2 (>= 2.4.38), libexpat1 (>= 2.0.1), libgbm1 (>= 8.1~0), libgcc1 (>= 1:3.0), libglib2.0-0 (>= 2.39.4), libgtk-3-0 (>= 3.9.10), libnspr4 (>= 2:4.9-2~), libnss3 (>= 2:3.22), libpango-1.0-0 (>= 1.14.0), libuuid1 (>= 2.16), libx11-6 (>= 2:1.4.99.1), libxcb1 (>= 1.9.2), libxcomposite1 (>= 1:0.4.4-1), libxdamage1 (>= 1:1.1), libxext6, libxfixes3, libxkbcommon0 (>= 0.4.1), libxrandr2, libxshmfence1, wget, xdg-utils (>= 1.0.2)
(Release Info) Pre-Depends: dpkg (>= 1.14.0)
(Release Info) Recommends: libu2f-udev, libvulkan1
(Release Info) Filename: pool/main/m/microsoft-edge-beta/microsoft-edge-beta_91.0.864.37-1_amd64.deb
(Release Info) Size: 99670130
(Release Info) MD5sum: 5357f4fc3dfed43dfb9f83e167448b5b
(Release Info) SHA1: 48411a8dab4004158845acbb60511747ea554117
(Release Info) SHA256: 1bf9cd3e6cb6d6ed7917a24035c574f2aecfc1b43544aceb9a56c2c51b4db922
(Release Info) SHA512: 4b3f57e26dd1d47f0ec55f3209d4d650e27e205cc83a80632cd4440b0d8525fe294951d52a392aae5c9e06346a3953cc8676545025117e9bc8b1a6cbde378c22
(Release Info) Description: The web browser from Microsoft
(Release Info) Microsoft Edge is a browser that combines a minimal design with sophisticated technology to make the web faster, safer, and easier.
(Release Info) (END)
2021-05-28T15:09:46+01:00 (DEBUG): Checking if there is an update available (release: 91.0.864.37) or if most recent version is already installed to the system...
2021-05-28T15:09:46+01:00 (DEBUG): Most recent version of Microsoft Edge (Beta) is already installed to the system (v91.0.864.37). Completed in 0m 0s. Exiting...(1)
2021-05-28T15:09:46+01:00 (DEBUG): EXIT signal was raised, cleaning up system after session before exiting...
2021-05-28T15:09:46+01:00 (CLEANER): Finished cleaning up system after session. Nice and clean :D Goodbye.
2021-05-28T15:09:46+01:00 (END): Total time for script execution was: 0m 0s

64
updater
View File

@ -8,6 +8,7 @@
# gunzip #
# tar #
# sort (coreutils >= 8.32) #
# notify-send #
# #
# #
# Disclaimer: This version only works for MS Edge Beta. #
@ -15,9 +16,9 @@
# and potentially both. #
# #
# Author: Ethan Smith-Coss #
# Version: 0.1.2 #
# Version: 0.1.3 #
# Created: 2021-05-20T16:47+0100 #
# Last Modified: 2021-05-23T21:18+0100 #
# Last Modified: 2021-05-28T12:54+0100 #
# #
# #################################### #
# #
@ -41,7 +42,7 @@
## program name
prog_name="Microsoft Edge Updater"
## version
version="0.1.2"
version="0.1.3"
## usage statement
usage="Usage: $(basename $0) [OPTION]
$prog_name ($version) - An updater program which can install the latest available version of Microsoft Edge to non-Debian-based Linux distros.
@ -49,16 +50,19 @@ $prog_name ($version) - An updater program which can install the latest availabl
DISCLAIMER: Currently this program can only update the Beta release of Microsoft Edge for amd64 architectures.
Options:
-nn, --no-notify Prevent notifications from being set after a session.
-y, --yes-all Assume yes to all yes/no decisions.
-v, --version Print out the version of the script and exit.
--help Print this help message and exit
-h, --help Print this help message and exit
"
runtime_dir=$(realpath "${BASH_SOURCE[0]}" | xargs -r dirname)
## runtime locations
log_file="$runtime_dir/.log.1"
logs_dir="$runtime_dir/logs"
tmp_path="/tmp/microsoft-edge-autoupdater"
garbage="$tmp_path/garbage.tmp"
## program timer
SECONDS=0
[[ ! -d "$logs_dir" ]] && mkdir "$logs_dir"
@ -68,9 +72,15 @@ SECONDS=0
function clean_up {
log "DEBUG" "EXIT signal was raised, cleaning up system after session before exiting..." "$log_file"
printf "Cleaning up system after session..."
cp "$log_file" "$logs_dir/updater.log" && rm "$log_file"
[[ -d "$tmp_path/opt" ]] && rm -r "$tmp_path/opt"
[[ -d "$tmp_path/usr" ]] && rm -r "$tmp_path/usr"
cp "$log_file" "$logs_dir/updater.log" # && rm "$log_file"
# [[ -d "$tmp_path/opt" ]] && rm -r "$tmp_path/opt"
# [[ -d "$tmp_path/usr" ]] && rm -r "$tmp_path/usr"
while read -r garbage_collection ; do
[[ -f "$garbage_collection" || -d "$garbage_collection" ]] && rm -r "$garbage_collection"
done < <(cat "$garbage")
[[ -f "$garbage" ]] && rm "$garbage"
log "CLEANER" "Finished cleaning up system after session. Nice and clean :D Goodbye." "$runtime_dir/logs/updater.log"
echo "done. Goodbye."
@ -88,7 +98,7 @@ while test $# -gt 0 ; do
-y | --yes-all)
yes_flag=0 ; shift
;;
--help)
-h | --help)
echo "$usage"
exit 0
;;
@ -96,22 +106,32 @@ while test $# -gt 0 ; do
echo "$prog_name ($version)"
exit 0
;;
-nn | --no-notify)
nn_flag=0 ; shift
;;
*)
shift
;;
esac
done
source "$runtime_dir/utils/common"
log "PREINIT" "----[New instance of script has been started: $(date -Iseconds)]----" "$log_file"
## setup the yes flag to automatically accept all yes/no inputs
yes_flag="${yes_flag:-1}"
log "DEBUG" "The yes flag has been set to: $yes_flag." "$log_file"
## check if the script is being ran as root - exit otherwise
[[ $(id -u) -ne 0 ]] && { echo "Please run script with root privilages." ; exit 1 ; }
# set trap to trigger clean up function on any exit
trap clean_up EXIT
source "$runtime_dir/utils/common"
log "PREINIT" "----[New instance of script has been started: $(date -Iseconds)]----" "$log_file"
echo "$log_file" >> "$garbage"
## setup the yes flag to automatically accept all yes/no inputs
yes_flag=${yes_flag:-1}
log "DEBUG" "The yes flag has been set to: $yes_flag." "$log_file"
## setup the no-notify (nn) flag if notify-send isn't installed
command -v notify-send >/dev/null 2>&1 || nn_flag=0
nn_flag=${nn_flag:-1}
## check if Microsoft Edge (Beta) is already installed
exit_code=$(command -v microsoft-edge-beta &>/dev/null)
[[ ! $exit_code -eq 0 ]] && { echo "Microsoft Edge (Beta) is not installed. Exiting updater..." ;
@ -135,6 +155,8 @@ echo "Checking to see if the host is known and reachable..."
if ! wget --spider "$host" >/dev/null 2>&1 ; then
echo "Cannot reach end-point for distribution information. Check your Internet connection and try again. Exiting..."
log "DEBUG" "Upstream end-point is cannot be contacted. Potential Internet connection issue or end-point address ($dist_upstream). Exiting...(3)" "$log_file"
[[ ! $nn_flag -eq 0 ]] && notify "Microsoft Edge (Beta) Update" "There seems to be an issue connecting to the end-point of Microsoft. Check your Internet connection and try again."
exit 3
fi
log "DEBUG" "Host is known and reachable. Continuing update to fetch data..." "$log_file"
@ -210,6 +232,7 @@ if [[ $upgradeable -eq 1 ]] ; then
script_time="$(($elapsed_time / 60))m $(($elapsed_time % 60))s"
echo "Most recent version of Microsoft Edge (Beta) [v$current_version] is already installed on this system, no need to update. Finished in $script_time"
log "DEBUG" "Most recent version of Microsoft Edge (Beta) is already installed to the system (v$current_version). Completed in $script_time. Exiting...(1)" "$log_file"
[[ ! $nn_flag -eq 0 ]] && notify "Microsoft Edge (Beta) Update" "There is no newer version of Microsoft Edge (Beta) to install. Newest version is already installed: v$current_version"
exit 1
fi
@ -251,6 +274,7 @@ log "DEBUG" "Checking the following release version file end-point is accessible
if ! wget --spider "$url" >/dev/null 2>&1 ; then
echo "Cannot reach end-point for latest release. Check your Internet connection and try again."
log "DEBUG" "Pool end-point is cannot be contacted. Potential Internet connection issue or end-point address ($url). Exiting...(5)" "$log_file"
[[ ! $nn_flag -eq 0 ]] && notify "Microsoft Edge (Beta) Update" "There seems to be an issue connecting to the end-point of Microsoft. Check your Internet connection and try again."
exit 5
fi
log "DEBUG" "Pool is known and reachable. Beginning download..." "$log_file"
@ -286,6 +310,8 @@ else
log "DEBUG" "File already downloaded to system. Skipped download and verifying checksum..." "$log_file"
printf "Latest Debian release file is downloaded to the system, skipping download. Validating checksums..."
fi
## add the .deb file to garbage list
echo "$tmp_path/$filename" >> "$garbage"
## verify the downloaded file
if [[ "$(sha256sum "$tmp_path/$filename" | cut -d' ' -f1)" != "$(grep 'SHA256:.*' "$tmp_path/Release" | cut -d' ' -f2)" ]] ; then
@ -293,6 +319,7 @@ if [[ "$(sha256sum "$tmp_path/$filename" | cut -d' ' -f1)" != "$(grep 'SHA256:.*
rm "$tmp_path/$filename"
log "DEBUG" "Checksum (SHA256) failed and integrity of file lost. File has been removed as either corrupt or hazardous/dangerous. Exiting...(7)" "$log_file"
echo -e "failed.\nThe checksum (SHA256) failed for some reason and removed either because it was corrupt or dangerous. Exiting updater...\n"
[[ ! $nn_flag -eq 0 ]] && notify "Microsoft Edge (Beta) Update" "There was an issue with the checksum to verify the latest release. The Debian file has been automatically removed to prevent potential danger to the system."
exit 7
fi
echo "complete."
@ -314,6 +341,8 @@ log "DEBUG" "Successfully extracted files from data.tar.gz." "$log_file"
echo "completed."
## etc/ directory only contains a cron daily directory, remove it
rm -r "$tmp_path/etc/"
## add data.tar.xz to the garbage list
echo "$tmp_path/data.tar.xz" >> "$garbage"
# compress archive the currently installed version of Edge (Beta) for restoration on failure
## :@TODO: compress everything on the system for a backup. Remove it if installation of new version was successful
@ -341,6 +370,9 @@ exit_code=$(cp -r "$tmp_path/usr" "/" >>"$log_file" 2>&1)
log "DEBUG" "There was an issue copying $tmp_path/usr/ file to system /usr/. Reverting system files and exiting...(9)" "$log_file" ; restore_files && exit 9 ; }
log "DEBUG" "Successfully installed files to their appropriate location." "$log_file"
echo "installation complete."
## add directories usr/ and opt/ to garbage
echo "$tmp_path/usr" >> "$garbage"
echo "$tmp_path/opt" >> "$garbage"
## confirm the update was successful - try to restore system otherwise
## :@TODO: validate new version has successfully installed properly - exit 12
@ -355,6 +387,7 @@ if [[ "$(microsoft-edge-beta --version | cut -d' ' -f3)" != "$release_version" ]
log "DEBUG" "System restoration was successful, safe to use; however, the update was still failed. Exiting...(11)" "$log_file"
echo -e "completed. However, there was still an issue trying to update Microsoft Edge (Beta) to the latest version." \
"Consult $log_file for more information. Exiting..."
[[ ! $nn_flag -eq 0 ]] && notify "Microsoft Edge (Beta) Update" "There was an issue installing the update to your system. The previous version, v$current_version, has been restored."
exit 11
fi
@ -362,4 +395,5 @@ fi
elapsed_time=$SECONDS
script_time="$(($elapsed_time / 60))m $(($elapsed_time % 60))s"
log "DEBUG" "Installation and update was successful (completed in: $script_time) and system can be cleaned up to remove any waste." "$log_file"
echo "Microsoft Edge (Beta) has been successfully updated to the latest version: v$release_version, in $script_time."
echo "Microsoft Edge (Beta) has been successfully updated to the latest version: v$current_version -> v$release_version, in $script_time."
[[ ! $nn_flag -eq 0 ]] && notify "Microsoft Edge (Beta) Update" "Successfully updated Microsoft Edge (Beta) to the latest version: v$release_version"

View File

@ -7,9 +7,9 @@
# #
# #
# Author: Ethan Smith-Coss #
# Version: 0.1.2 #
# Version: 0.1.3 #
# Created: 2021-05-20T16:47+0100 #
# Last Modified: 2021-05-23T23:06+0100 #
# Last Modified: 2021-05-27T15:34+0100 #
# #
# #################################### #
# #
@ -32,7 +32,7 @@
#########################################################################
function log {
local log_out=$(realpath "${0%/*}/../.log.1")
local log_out=$(realpath "${0%/*}/.log.1")
[[ $# -eq 0 ]] && log "ERROR" "Log function was called without any arguments. Returning 1." "$log_out" && return 1
[[ ! $# -eq 3 ]] && log "ERROR" "Log function expected at least 3 arguments, recieved $#. Returning 1." "$log_out" && return 1
$(echo "$(date -Iseconds) ($1): $2" >> "$3") >/dev/null 2>&1
@ -42,24 +42,24 @@ function log {
}
function archive_system {
local log_out=$(realpath "${0%/*}/../.log.1")
local log_out=$(realpath "${0%/*}/.log.1")
[[ -e $1 ]] && log "ERROR" "Archive function was called without any arguments." "$log_out"
local archive_output="$/tmp/microsoft-edge-autoupdater/$(echo $1 | sed 's/\//_/').tar.gz"
local archive_output="/tmp/microsoft-edge-autoupdater/$(echo $1 | sed 's/\//_/').tar.gz"
[[ -f "$archive_output" ]] && return 0
exit_code=$(grep 'usr/.*' "/tmp/microsoft-edge-autoupdater/Contents-amd64" | tar --overwrite -cvzf "$archive_output" "/opt/$1/" >>"$log_out" 2>&1 )
exit_code=$(grep 'usr/.*' "/tmp/microsoft-edge-autoupdater/Contents-amd64" | tar --overwrite -cvzf "$archive_output" "/opt/$1/" 2>>"$log_out")
[[ ! $exit_code -eq 0 ]] && { log "ERROR" "(Archive) There was an issue creating the archive file of system. Returning...(10)" "$log_out" ; return 10 ; }
return 0
}
function restore_files {
local log_out=$(realpath "${0%/*}/../.log.1")
local log_out=$(realpath "${0%/*}/.log.1")
[[ -e $1 ]] && log "ERROR" "Restore function was called without any arguments." "$log_out"
local backup_file="/tmp/microsoft-edge-autoupdater/$(echo $1 | 's/\/_/').tar.gz"
local backup_file="/tmp/microsoft-edge-autoupdater/$(echo $1 | 's/\//_/').tar.gz"
[[ -f "$backup_file" ]] && { log "ERROR" "There is no backup of Microsoft Edge (Beta) identified. Restoration not possible." "$log_out" ; return 12 ; }
exit_code=$( tar -xvzf "$backup_file" "/" >>"$log_out" 2>&1)
exit_code=$( tar -xvzf "$backup_file" "/" 2>>"$log_out")
[[ ! $exit_code -eq 0 ]] && { log "ERROR" "There was an issue restoring pervious files to system." \
"The backup created will not be removed to allow for manual restoration. Returning...(12)" ; return 12 ; }
@ -68,5 +68,11 @@ function restore_files {
function notify {
## :@TODO: implement notification system.
local log_out=$(realpath "${0%/*}/.log.1")
[[ $# -eq 0 ]] && log "ERROR" "Notify function was called without any arguments. Returning 1." "$log_out" && return 1
[[ ! $# -eq 2 ]] && log "ERROR" "Notify function expected at least 2 arguments, recieved $#. Returning 1." "$log_out" && return 1
exit_code=$(notify-send "$1" "$2" >>"$log_out" 2>&1) && tput bel
[[ ! $exit_code -eq 0 ]] && log "ERROR" "There was an issue send a notification to the system." "$log_out"
return 0
}