7 Commits
Author SHA1 Message Date
bruno 11bad4f0cd test 2025-01-06 10:35:31 +01:00
bruno ddb25adba3 v1.1.4 2025-01-06 09:48:12 +01:00
bruno 54532c7f23 test 2025-01-06 09:44:48 +01:00
bruno 9debf8e7f9 test 2025-01-06 09:41:58 +01:00
bruno 9166fe0e8b ChangeNotes
change to curl -s -r 0-1000
2025-01-06 09:28:09 +01:00
bruno bdb26651b1 v 1.1.3
-won’t display changes notes
2025-01-06 09:23:46 +01:00
bruno 9e9a58ff9f v1.1.1
bugfix with .env path
2025-01-06 09:02:32 +01:00
+39 -32
View File
@@ -1,6 +1,42 @@
#!/usr/bin/env bash #!/usr/bin/env bash
VERSION="v1.1" VERSION="v1.1.4"
### Variables for self updating
ScriptArgs=( "$@" )
ScriptPath="$(readlink -f "$0")" # /Users/bruno/Documents/Scripts/bashbirds/bashbirds.sh
ScriptWorkDir="$(dirname "$ScriptPath")" # /Users/bruno/Documents/Scripts/bashbirds
dotenv () {
set -a
# shellcheck disable=SC1091
[ -f "$ScriptWorkDir/.env" ] && . "$ScriptWorkDir/.env" || echo -e "${red}\nNo .env file found ! Could'nt get update from Github.'.${reset}"
set +a
}
dotenv
### ChangeNotes: 1.1.4 curl 2ko
### ChangeNotes: 1.1.3 Won't display Changes notes
### ChangeNotes: 1.1.1 Bugfix .env path
### ChangeNotes: 1.1 Bugfix when script was run with symlink
### ChangeNotes: 1.0 Minor corrections.
Github="https://github.com/bruno21/bashbirds"
# Public Repo:
#RawUrl="https://raw.githubusercontent.com/Bruno21/bashbirds/main/bashbirds.sh"
# Private Repo:
RawUrl="https://x-access-token:$GITHUB_TOKEN@raw.githubusercontent.com/Bruno21/bashbirds/main/bashbirds.sh"
### Check if there's a new release of the script:
LatestRelease="$(curl -s -r 0-50 $RawUrl | sed -n "/VERSION/s/VERSION=//p" | tr -d '"')"
#LatestChanges="$(curl -s -r 0-2000 $RawUrl | sed -n "/ChangeNotes/s/# ChangeNotes: //p")"
LatestChanges="$(curl -s -r 0-2000 $RawUrl | grep "^### ChangeNotes:" | sed 's/### ChangeNotes://g')"
#[[ $LatestRelease != $VERSION ]] && new="($LatestRelease)" || new=""
#echo "$LatestRelease"
#echo "$LatestChanges"
red="\033[1;31m" red="\033[1;31m"
greenbold="\033[1;32m" greenbold="\033[1;32m"
@@ -13,31 +49,6 @@ italic="\033[3m"
underline="\033[4m" underline="\033[4m"
reset="\033[0m" reset="\033[0m"
dotenv () {
set -a
# shellcheck disable=SC1091
[ -f ".env" ] && . ".env" || echo -e "${red}\nNo .env file found ! Could'nt get update from Github.'.${reset}"
set +a
}
dotenv
### ChangeNotes: Minor corrections.
Github="https://github.com/bruno21/bashbirds"
# Repo normal:
#RawUrl="https://raw.githubusercontent.com/Bruno21/bashbirds/main/bashbirds.sh"
# Repo privé:
RawUrl="https://x-access-token:$GITHUB_TOKEN@raw.githubusercontent.com/Bruno21/bashbirds/main/bashbirds.sh"
### Variables for self updating
ScriptArgs=( "$@" )
ScriptPath="$(readlink -f "$0")" # /Users/bruno/Documents/Scripts/bashbirds/bashbirds.sh
ScriptWorkDir="$(dirname "$ScriptPath")" # /Users/bruno/Documents/Scripts/bashbirds
### Check if there's a new release of the script:
LatestRelease="$(curl -s -r 0-50 $RawUrl | sed -n "/VERSION/s/VERSION=//p" | tr -d '"')"
LatestChanges="$(curl -s -r 0-200 $RawUrl | sed -n "/ChangeNotes/s/### ChangeNotes: //p")"
#[[ $LatestRelease != $VERSION ]] && new="($LatestRelease)" || new=""
echo -e "${yellowbold}Bashbird${reset} $VERSION\n" echo -e "${yellowbold}Bashbird${reset} $VERSION\n"
@@ -71,7 +82,6 @@ req2() {
#read -p "Pause: " choice #read -p "Pause: " choice
#query2="SELECT * FROM liste;"
query2="SELECT Francais, Autres, Latin, Anglais, Ordre, Famille, Liens FROM liste;" query2="SELECT Francais, Autres, Latin, Anglais, Ordre, Famille, Liens FROM liste;"
result2=$(sqlite3 "$ScriptWorkDir/birds.db" "$query2") result2=$(sqlite3 "$ScriptWorkDir/birds.db" "$query2")
#echo "$result2" #echo "$result2"
@@ -90,9 +100,6 @@ req2() {
ln="${array[6]}" ln="${array[6]}"
#echo "$ln"
#read -r -p "Would you like to update? y/[n]: " SelfUpdate
[[ $aut != "" ]] && z="($aut)" || z="" [[ $aut != "" ]] && z="($aut)" || z=""
if [ $ext = ".md" ]; then if [ $ext = ".md" ]; then
@@ -335,7 +342,7 @@ self_update_curl() {
if [[ $(builtin type -P curl) ]]; then if [[ $(builtin type -P curl) ]]; then
curl -L $RawUrl > "$ScriptPath" ; chmod +x "$ScriptPath" curl -L $RawUrl > "$ScriptPath" ; chmod +x "$ScriptPath"
printf "\n%s\n" "--- starting over with the updated version ---" printf "\n%s\n" "--- starting over with the updated version ---"
exec "$ScriptPath" "${ScriptArgs[@]}" # run the new script with old arguments exec "$ScriptPath" "${ScriptArgs[@]}" >/dev/null # run the new script with old arguments
exit 1 # exit the old instance exit 1 # exit the old instance
elif [[ $(builtin type -P wget) ]]; then elif [[ $(builtin type -P wget) ]]; then
wget $RawUrl -O "$ScriptPath" ; chmod +x "$ScriptPath" wget $RawUrl -O "$ScriptPath" ; chmod +x "$ScriptPath"
@@ -364,7 +371,7 @@ self_update() {
### Version check & initiate self update ### Version check & initiate self update
if [[ "$VERSION" != "$LatestRelease" ]] ; then if [[ "$VERSION" != "$LatestRelease" ]] ; then
printf "New version available! %b%s%b ⇒ %b%s%b \n Change Notes: %s \n" "$c_yellow" "$VERSION" "$c_reset" "$c_green" "$LatestRelease" "$c_reset" "$LatestChanges" printf "New version available! %b%s%b ⇒ %b%s%b \nChange Notes:\n%s \n" "$c_yellow" "$VERSION" "$c_reset" "$c_green" "$LatestRelease" "$c_reset" "$LatestChanges"
if [[ -z "$AutoUp" ]] ; then if [[ -z "$AutoUp" ]] ; then
read -r -p "Would you like to update? y/[n]: " SelfUpdate read -r -p "Would you like to update? y/[n]: " SelfUpdate
[[ "$SelfUpdate" =~ [yY] ]] && self_update [[ "$SelfUpdate" =~ [yY] ]] && self_update