add -g flag for google-chrome to chromium script

refactor hugo install to use lastversion
master
Kebler Network System Administrator 2021-11-02 07:01:28 -07:00
parent d5d76efa8d
commit ff9c178611
2 changed files with 78 additions and 70 deletions

View File

@ -6,8 +6,11 @@ chromium_() {
local DEFAULT=/opt/chromium local DEFAULT=/opt/chromium
# local DEFAULT="$HOME/.local/share/chromium" # local DEFAULT="$HOME/.local/share/chromium"
local exe="/usr/bin/chromium" local exe="/usr/bin/chromium"
[[ $1 == -g ]] && exe=$(command -v google-chrome) && shift
echo exe $exe
if [[ ! -f $exe ]]; then if [[ ! -f $exe ]]; then
echo deb chromium not installed, checking for flatpak version echo chromium/chrome not installed, checking for flatpak version
flatpak=$(flatpak info com.github.Eloston.UngoogledChromium | grep error:) flatpak=$(flatpak info com.github.Eloston.UngoogledChromium | grep error:)
if [[ $flatpak ]]; then if [[ $flatpak ]]; then
echo no flatpak version either - exiting && return 1 echo no flatpak version either - exiting && return 1
@ -44,6 +47,8 @@ chromium_() {
dir=${CHROMIUM_HOME:-$DEFAULT}/$instance dir=${CHROMIUM_HOME:-$DEFAULT}/$instance
exe="${exe/<dir>/$dir}" exe="${exe/<dir>/$dir}"
fi fi
mkdir -p $dir
echo $exe $@ --user-data-dir=$dir $url $([[ $flatpak ]] && echo "@@")
$exe $@ --user-data-dir=$dir $url $([[ $flatpak ]] && echo "@@") $exe $@ --user-data-dir=$dir $url $([[ $flatpak ]] && echo "@@")
} }

View File

@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
hugo_install () { hugo_install() {
# inspried from this forum post https://discourse.gohugo.io/t/script-to-install-latest-hugo-release-on-macos-and-ubuntu/14774/10 # inspried from this forum post https://discourse.gohugo.io/t/script-to-install-latest-hugo-release-on-macos-and-ubuntu/14774/10
# if you have run into github api anonymous access limits which happens during debugging/dev then add user and token here or sourced from a separate file # if you have run into github api anonymous access limits which happens during debugging/dev then add user and token here or sourced from a separate file
# . ~/githubapitoken # . ~/githubapitoken
@ -16,7 +16,6 @@ hugo_install () {
FORCE=false FORCE=false
EFILE="" EFILE=""
# options # options
# e - download and install the extended version # e - download and install the extended version
# c - use 'hugoe' as the install command for extended version otherwise 'hugo' will launch extended version # c - use 'hugoe' as the install command for extended version otherwise 'hugo' will launch extended version
@ -28,24 +27,24 @@ hugo_install () {
while getopts 'ecf' OPTION; do while getopts 'ecf' OPTION; do
case "$OPTION" in case "$OPTION" in
e) e)
echo "installing extended hugo" echo "installing extended hugo"
EXTENDED=true EXTENDED=true
;; ;;
c) c)
if [ $EXTENDED = true ]; then if [ $EXTENDED = true ]; then
EFILE="e" EFILE="e"
echo using hugoe for extended command echo using hugoe for extended command
fi fi
;; ;;
f) f)
echo "FORCING download/overwrite" echo "FORCING download/overwrite"
FORCE=true FORCE=true
;; ;;
esac esac
done done
shift $(( OPTIND - 1 )) shift $((OPTIND - 1))
DEFAULT_BIN_DIR="/usr/local/bin" DEFAULT_BIN_DIR="/usr/local/bin"
# Single optional argument is directory in which to install hugo # Single optional argument is directory in which to install hugo
@ -53,49 +52,53 @@ hugo_install () {
BIN_PATH="$(which hugo$EFILE)" BIN_PATH="$(which hugo$EFILE)"
declare -A ARCHES declare -A ARCHES
ARCHES=( ["arm64"]="ARM64" ["aarch64"]="ARM64" ["x86_64"]="64bit" ["arm32"]="ARM" ["armhf"]="ARM" ) ARCHES=(["arm64"]="ARM64" ["aarch64"]="ARM64" ["x86_64"]="64bit" ["arm32"]="ARM" ["armhf"]="ARM")
ARCH=$(arch) ARCH=$(arch)
if [ -z "${ARCHES[$ARCH]}" ]; then if [ -z "${ARCHES[$ARCH]}" ]; then
echo Your machine kernel architecture $ARCH is not supported by this script, aborting echo Your machine kernel architecture $ARCH is not supported by this script, aborting
exit 1 exit 1
fi fi
INSTALLED="$(hugo$EFILE version 2>/dev/null | cut -d'v' -f2 | cut -c 1-6)" INSTALLED="$(hugo$EFILE version 2>/dev/null | cut -d'v' -f2 | cut -c 1-6)"
CUR_VERSION=${INSTALLED:-"None"} CUR_VERSION=${INSTALLED:-"None"}
echo $(curl -u $GITHUB_USER:$GITHUB_TOKEN -s https://api.github.com/repos/gohugoio/hugo/releases/latest | grep tag_name) # echo $(curl -u $GITHUB_USER:$GITHUB_TOKEN -s https://api.github.com/repos/gohugoio/hugo/releases/latest | grep tag_name)
NEW_VERSION="$(curl -u $GITHUB_USER:$GITHUB_TOKEN -s https://api.github.com/repos/gohugoio/hugo/releases/latest \ # NEW_VERSION="$(curl -u $GITHUB_USER:$GITHUB_TOKEN -s https://api.github.com/repos/gohugoio/hugo/releases/latest \
| grep tag_name \ # | grep tag_name \
| cut -d'v' -f2 | cut -c 1-6)" # | cut -d'v' -f2 | cut -c 1-6)"
echo "Hugo `[ $EXTENDED == true ] && echo "Extended"`: Current Version : $CUR_VERSION => New Version: $NEW_VERSION" NEW_VERSION=$(lastversion hugo)
if [ -z "$NEW_VERSION" ]; then echo "Hugo $([ $EXTENDED == true ] && echo "Extended"): Current Version : $CUR_VERSION => New Version: $NEW_VERSION"
echo Unable to retrieve new version number - Likely you have reached github anonymous limit
echo set environment variable `$GITHUB_USER` and `$GITHUB_TOKEN` and try again
exit 1
fi
[[ $NEW_VERSION = $CUR_VERSION ]] && [[ $FORCE = false ]] && echo Latest version already installed at $BIN_PATH && return 0 # if [ -z "$NEW_VERSION" ]; then
# echo Unable to retrieve new version number - Likely you have reached github anonymous limit
# echo set environment variable $($GITHUB_USER) and $($GITHUB_TOKEN) and try again
# exit 1
# fi
pushd /tmp/ > /dev/null [[ $NEW_VERSION = $CUR_VERSION ]] && [[ $FORCE = false ]] && echo Latest version already installed at $BIN_PATH && return 0
URL=$(curl -u $GITHUB_USER:$GITHUB_TOKEN -s https://api.github.com/repos/gohugoio/hugo/releases/latest \ pushd /tmp/ >/dev/null
| grep "browser_download_url.*hugo.*._Linux-${ARCHES[$ARCH]}\.tar\.gz" \
| \ # curl -u $GITHUB_USER:$GITHUB_TOKEN -s https://api.github.com/repos/gohug#oio/hugo/releases/latest |
if [ $EXTENDED = true ]; then # grep "browser_download_url.*hugo.*._Linux-${ARCHES[$ARCH]}\.tar\.gz" |
grep "_extended"
else URL=$(
grep -v "_extended" lastversion hugo --format assets --filter Linux-${ARCHES[$ARCH]}\.tar\.gz |
fi \ if [ $EXTENDED = true ]; then
| cut -d ":" -f 2,3 \ grep "_extended"
| tr -d \" \ else
grep -v "_extended"
fi
# |
# cut -d ":" -f 2,3 |
# tr -d \"
) )
echo $URL echo $URL
echo "Installing version $NEW_VERSION `[ $EXTENDED == true ] && echo "Extended"` " echo "Installing version $NEW_VERSION $([ $EXTENDED == true ] && echo "Extended") "
echo "This machine's architecture is $ARCH" echo "This machine's architecture is $ARCH"
echo "Downloading Tarball $URL" echo "Downloading Tarball $URL"
@ -118,9 +121,9 @@ hugo_install () {
rm $TARBALL rm $TARBALL
popd > /dev/null popd >/dev/null
echo Installing hugo `[ $EXTENDED == true ] && echo "extended"` as hugo$EFILE echo Installing hugo $([ $EXTENDED == true ] && echo "extended") as hugo$EFILE
BIN_PATH="$(which hugo$EFILE)" BIN_PATH="$(which hugo$EFILE)"