Skip to content

Commit

Permalink
Fixed annoying bug when trying to download from dead links. Added --c…
Browse files Browse the repository at this point in the history
…heck to test for dead links in oslist repository.
  • Loading branch information
gnarlin committed Mar 26, 2023
1 parent 1f406b6 commit 4130af1
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 11 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,9 @@ Osget 1.4
Osget 1.5
19.02.2022 Freyr Ólafsson gnarlin@fripost.org
* Updated oslist with a large contribution from Jeremy Wakeman. Thank you.
Osget 1.6
26.03.2023 Freyr Ólafsson gnarlin@fripost.org
* Fixed a super annoying bug where if you tried to download but the oslist entry
had a dead link osget would get confused and freeze with an empty http entry.
* Added --check which goes through every URL in every oslist file and checks to see
if the links are dead or still up. It even has colour codes for OK or Down.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ sudo ./install.sh --install
```
You can also use the debian package on Debian based distributions:
```shell
sudo apt install ./osget_1.5_all.deb
sudo apt install ./osget_1.6_all.deb
```
If you want to use the tradition method:
```shell
sudo dpkg -i osget_1.5_all.deb
sudo dpkg -i osget_1.6_all.deb
```
This uninstalls osget, all configuration files and the oslist repository:
```shell
Expand Down
2 changes: 1 addition & 1 deletion etc/osget/osget.conf
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ USE_TORRENT="0"
#Note that any additional repositories added to the oslist
#will overwrite them if the names in the subsequent repos are
#the same as the ones from the previous repos.
OSLIST_REPOSITORY1="ftp://46.22.104.24/oslist"
OSLIST_REPOSITORY1="ftp://89.17.142.188/oslist"
#OSLIST_REPOSITORY2=""
#OSLIST_REPOSITORY3=""
8 changes: 4 additions & 4 deletions install.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#! /bin/bash
#
# file: installer.sh
# This is osget version 1.5
# This is osget version 1.6
# written by Freyr Gunnar Ólafsson
# This program is licenced under the GPL version 3 or higher (if available)

function id_bin ()
id_bin ()
{
local tmp=""
if [ -x /usr/bin/id ];then
Expand All @@ -31,7 +31,7 @@ checkif_root ()

#This is where osget will be installed.
TARGET="/usr/bin"
VERSION="1.5"
VERSION="1.6"
ID=""

#check if the files exist
Expand Down Expand Up @@ -97,7 +97,7 @@ if [ "$1" = "--help" ] || [ "$1" = "-h" ] || [ "$#" = "0" ];then
echo "--force-install will install AND override files if there are any."
echo "--uninstall will uninstall osget and remove all config files."
echo ""
echo "install by typing the following: ./install.sh --install."
echo "install by typing the following either as root or with sudo: sudo ./install.sh --install"
fi

if [ "$1" = "--uninstall" ];then
Expand Down
30 changes: 26 additions & 4 deletions osget
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ else
readonly CONFIGURATION_DIR="$OSDEV_CONFIGURATION_DIR"
fi

VERSION="1.5"
VERSION="1.6"

# shellcheck source=/etc/osget/osget.conf
source $CONFIGURATION_DIR/osget.conf
Expand All @@ -32,6 +32,7 @@ osget is a command line utility to easily download different operating systems
--search or -s Search from all available operating system names.
--torrent or -t Use bittorrent to download.
--update or -u Update the repository of operating systems available to download from an online source.
--check or -c Checks the oslist repository for dead links.
EXAMPLE: osget -d ~/Downloads/ debian-11.0.0-amd64-netinst
You can also use the generic names of Operating systems which will download the most common version.
Expand All @@ -41,6 +42,26 @@ This is determined with a "default" symlink in the oslist subdirectories.
EOF
}

scan_oslist () {
for file in $(find "$CONFIGURATION_DIR"/oslist/* -type f -print|grep -v "txt");do

source $file

for (( i=1 ; ; i++ )); do
n="URL${i}" # the name of var
[ "${!n+x}" ] || break # see if it exists
if (validate_url ${!n});then
echo -e "${!n} is \e[42mUP!\e[0m"
URL="${!n}"
break
else
echo -e "${!n} is \e[41mDOWN!\e[0m"
fi
done

done
}

list_osnames () {
ls -1 $CONFIGURATION_DIR/oslist/
}
Expand Down Expand Up @@ -212,7 +233,7 @@ if [ "$1" = "--help" ] || [ "$1" = "-h" ] || [ "$#" -eq "0" ];then
fi


OPTS=$(getopt -o hvloui:d:s:t: --long help,version,list,listosnames,update,information:,directory:,search:,torrent: -n 'osget' -- "$@")
OPTS=$(getopt -o hvlouci:d:s:t: --long help,version,list,listosnames,update,check,information:,directory:,search:,torrent: -n 'osget' -- "$@")
eval set -- "$OPTS"

while true; do
Expand All @@ -222,6 +243,7 @@ while true; do
-l | --list ) list; shift ;;
-o | --listosnames ) list_osnames; shift ;;
-u | --update ) update_oslist; shift ;;
-c | --check ) scan_oslist; shift ;;
-i | --information ) get_information "$2"; shift 2 ;;
-d | --directory ) DOWNLOAD_DIR="$2"; shift 2 ;;
-s | --search ) search "$2"; shift 2 ;;
Expand Down Expand Up @@ -250,7 +272,7 @@ for par in "$@";do

for (( i=1 ; ; i++ )); do
n="URL${i}" # the name of var
[ "${!n+x}" ] || break # see if it exists
[ "${!n+x}" ] || exit # see if it exists
if (validate_url ${!n});then
URL="${!n}"
break
Expand Down Expand Up @@ -280,7 +302,7 @@ for par in "$@";do

for (( i=1 ; ; i++ )); do
n="URL${i}" # the name of var
[ "${!n+x}" ] || break # see if it exists
[ "${!n+x}" ] || exit # see if it exists
if (validate_url ${!n});then
URL="${!n}"
break
Expand Down
Binary file modified osget.8.gz
Binary file not shown.
Binary file removed osget_1.5_all.deb
Binary file not shown.
Binary file added osget_1.6.deb
Binary file not shown.

0 comments on commit 4130af1

Please sign in to comment.