From 6b78c20555033d9b836bbe9bffef93f65f18278e Mon Sep 17 00:00:00 2001 From: Rob Watson Date: Sat, 7 Oct 2023 10:43:32 +0200 Subject: [PATCH] chore(script): apply shellcheck fixes --- script/batinfo | 4 +-- script/branchname | 5 ++- script/cleanvimplugins | 8 ++--- script/createrepo | 59 ----------------------------------- script/deletevimplugin | 2 +- script/dellines | 2 +- script/gensshkey | 4 +-- script/ghci | 4 +-- script/ghco | 5 +-- script/ghpr | 2 +- script/gitsha1yank | 2 +- script/installalacritty | 26 +++++++-------- script/installdotfiles | 34 ++++++++++---------- script/installnvim | 12 +++---- script/installpackages | 4 +-- script/installpackagesnonroot | 3 +- script/installvim | 28 ----------------- script/installvimplugins | 12 +++---- script/jira | 9 +++--- script/ksc | 4 +-- script/myip | 8 ++--- script/sysinfo | 2 +- script/tmuxsess | 14 ++++----- script/unstagebranch | 19 ----------- script/updateaurpackages | 4 ++- script/updatedevenv | 4 ++- script/updateinvidious | 27 ---------------- script/updatenetflux | 12 ------- script/updatevim | 1 - script/updatevimplugins | 12 +++---- script/uuidprint | 2 ++ script/uuidyank | 2 ++ script/wgdown | 2 +- script/wgup | 2 +- 34 files changed, 102 insertions(+), 238 deletions(-) delete mode 100755 script/createrepo delete mode 100755 script/installvim delete mode 100755 script/unstagebranch delete mode 100755 script/updateinvidious delete mode 100755 script/updatenetflux delete mode 120000 script/updatevim diff --git a/script/batinfo b/script/batinfo index 2b5eee8..dff5634 100755 --- a/script/batinfo +++ b/script/batinfo @@ -4,8 +4,8 @@ set -e -if [ $(uname -s) = "Darwin" ]; then +if [ "$(uname -s)" = "Darwin" ]; then echo "" # TODO else # Linux - echo "$(cat /sys/class/power_supply/BAT0/capacity)" + cat /sys/class/power_supply/BAT0/capacity fi diff --git a/script/branchname b/script/branchname index fa94013..ede06c6 100755 --- a/script/branchname +++ b/script/branchname @@ -8,8 +8,7 @@ set -e branchname=$(git bn) if [ "$branchname" = "HEAD" ]; then - branchoutput=$(git branch --list | grep rebasing) - if [ ! $? -eq 0 ]; then + if ! branchoutput=$(git branch --list | grep rebasing); then exit 1 fi @@ -21,4 +20,4 @@ if [ "$branchname" = "HEAD" ]; then fi fi -printf $branchname +printf "%s" "$branchname" diff --git a/script/cleanvimplugins b/script/cleanvimplugins index ef4bf17..33d8663 100755 --- a/script/cleanvimplugins +++ b/script/cleanvimplugins @@ -9,11 +9,11 @@ set -e pluginhome=$HOME/.vim/pack/git-plugins -cd $pluginhome/opt -find . -mindepth 1 -maxdepth 1 -type d -print0 | while read -d $'\0' pluginpath +cd "$pluginhome/opt" +find . -mindepth 1 -maxdepth 1 -type d -print0 | while read -rd $'\0' pluginpath do - if ! grep -q "$pluginpath" $HOME/.config/nvim/init.vim ; then - basename=$(basename $pluginpath) + if ! grep -q "$pluginpath" "$HOME/.config/nvim/init.vim" ; then + basename=$(basename "$pluginpath") echo "rm -rf $pluginhome/opt/$basename" fi done diff --git a/script/createrepo b/script/createrepo deleted file mode 100755 index 1619a8c..0000000 --- a/script/createrepo +++ /dev/null @@ -1,59 +0,0 @@ -#!/usr/bin/env ruby -# -# frozen_string_literal: true - -# Create a Git repo on git.netflux.io - -require 'json' -require 'net/http' -require 'optparse' -require 'uri' - -options = {} -banner = 'Usage: createrepo [options] ' - -OptionParser.new do |opts| - opts.banner = banner - - opts.on('--private', 'Make repo private') do |v| - options[:private] = v - end - - opts.on('-d', '--description=DESC', 'Description') do |v| - options[:description] = v - end -end.parse! - -options[:name] = ARGV.pop.to_s.strip -if options[:name].empty? - puts banner - exit 1 -end - -auth_token = ENV['GIT_NETFLUX_IO_TOKEN'] -if !auth_token || auth_token.empty? - puts 'Env var GIT_NETFLUX_IO_TOKEN must be set' - exit 1 -end - -uri = URI('https://git.netflux.io/api/v1/user/repos') -auth_string = "token #{auth_token}" - -req = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json', 'Authorization' => auth_string) -req.body = options.to_json - -Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http| - resp = http.request(req) - if resp.code != '201' - begin - errmsg = JSON.parse(resp.body) - puts errmsg['message'] - rescue JSON::ParserError - puts resp.body - end - exit 1 - end - - repo = JSON.parse(resp.body) - puts "git remote add origin #{repo['ssh_url']}" -end diff --git a/script/deletevimplugin b/script/deletevimplugin index b337f16..c231f55 100755 --- a/script/deletevimplugin +++ b/script/deletevimplugin @@ -26,7 +26,7 @@ if [ ! -d "$path" ]; then exit 1 fi -rm -rf $path +rm -rf "$path" echo "Deleted $basename" diff --git a/script/dellines b/script/dellines index a67e402..174e59c 100755 --- a/script/dellines +++ b/script/dellines @@ -18,7 +18,7 @@ if [ -z "$filepattern" ]; then filepattern="*" fi -if [ $(uname -s) = "Linux" ]; then +if [ "$(uname -s)" = "Linux" ]; then echo "TODO: fix for Linux" fi diff --git a/script/gensshkey b/script/gensshkey index a26e007..5b19cb9 100755 --- a/script/gensshkey +++ b/script/gensshkey @@ -5,5 +5,5 @@ set -e -ssh-keygen -o -a 100 -t ed25519 -f $HOME/.ssh/id_ed25519 -C "$USER@$(hostname -s)" -cat $HOME/.ssh/id_ed25519.pub +ssh-keygen -o -a 100 -t ed25519 -f "$HOME/.ssh/id_ed25519" -C "$USER@$(hostname -s)" +cat "$HOME/.ssh/id_ed25519.pub" diff --git a/script/ghci b/script/ghci index e51a06f..c141bcb 100755 --- a/script/ghci +++ b/script/ghci @@ -13,9 +13,9 @@ if ! echo "$ghoutput" | grep -q 'https://'; then exit 1 fi -url=$(echo $ghoutput | grep -o 'https://.*?' | tr -d '?') +url=$(echo "$ghoutput" | grep -o 'https://.*?' | tr -d '?') -if [ $(uname -s) = "Linux" ]; then +if [ "$(uname -s)" = "Linux" ]; then progname="xdg-open" else progname="open" # macOS diff --git a/script/ghco b/script/ghco index 688c6e9..f748143 100755 --- a/script/ghco +++ b/script/ghco @@ -9,6 +9,7 @@ unset BROWSER if [ "$1" = '-a' ]; then cmd='gh pr list --limit 100' elif [ -z "$GITHUB_USERNAME" ]; then + # shellcheck disable=SC2016 echo 'set $GITHUB_USERNAME first' exit 1 else @@ -16,7 +17,7 @@ else fi prid=$(eval "$cmd" | fzf | awk '{print $1}') -if [ -z $prid ]; then +if [ -z "$prid" ]; then exit 0 fi -gh pr checkout $prid +gh pr checkout "$prid" diff --git a/script/ghpr b/script/ghpr index 6b3727c..5545907 100755 --- a/script/ghpr +++ b/script/ghpr @@ -22,6 +22,6 @@ if echo "$output" | grep -q "no pull requests found"; then echo "Opening new PR..." gh pr create -w else - echo $output + echo "$output" exit $exitcode fi diff --git a/script/gitsha1yank b/script/gitsha1yank index e003a53..c8a2e53 100755 --- a/script/gitsha1yank +++ b/script/gitsha1yank @@ -9,4 +9,4 @@ if [ "$1" = "-s" ]; then fi # TODO: fix for non-Darwin -git rev-parse $args HEAD | tr -d '\n' | pbcopy +git rev-parse "$args" HEAD | tr -d '\n' | pbcopy diff --git a/script/installalacritty b/script/installalacritty index a74018d..19decc3 100755 --- a/script/installalacritty +++ b/script/installalacritty @@ -14,27 +14,27 @@ if ! [ -x "$(command -v cargo)" ]; then exit 1 fi -mkdir -p $HOME/dev $HOME/bin +mkdir -p "$HOME/dev" "$HOME/bin" destdir=$HOME/dev/alacritty -if [ -d $destdir ]; then +if [ -d "$destdir" ]; then echo "Updating alacritty..." - cd $destdir + cd "$destdir" git pull --rebase else echo "Cloning alacritty..." - cd $HOME/dev + cd "$HOME/dev" git clone -q https://github.com/alacritty/alacritty.git alacritty fi -cd $destdir +cd "$destdir" echo "Building alacritty..." -if [ $(uname -s) = "Darwin" ]; then +if [ "$(uname -s)" = "Darwin" ]; then make app - sudo cp -av $destdir/target/release/osx/Alacritty.app /Applications/ + sudo cp -av "$destdir/target/release/osx/Alacritty.app" /Applications/ else cargo build --release echo "Installing alacritty..." - cp $destdir/target/release/alacritty $HOME/bin/alacritty + cp "$destdir/target/release/alacritty" "$HOME/bin/alacritty" fi if [ -z "$ZDOTDIR" ]; then @@ -44,13 +44,13 @@ fi echo "Installing ZSH completions..." funcdir=$ZDOTDIR/functions -mkdir -p $funcdir -cp $destdir/extra/completions/_alacritty $funcdir/_alacritty +mkdir -p "$funcdir" +cp "$destdir/extra/completions/_alacritty" "$funcdir/_alacritty" -if [ $(uname -s) = "Linux" ]; then +if [ "$(uname -s)" = "Linux" ]; then # TODO: fix for Manjaro/xfce4: - sudo cp $destdir/extra/logo/alacritty-term.svg /usr/share/pixmaps/Alacritty.svg - sudo desktop-file-install $destdir/extra/linux/Alacritty.desktop + sudo cp "$destdir/extra/logo/alacritty-term.svg" /usr/share/pixmaps/Alacritty.svg + sudo desktop-file-install "$destdir/extra/linux/Alacritty.desktop" sudo update-desktop-database fi diff --git a/script/installdotfiles b/script/installdotfiles index f94501b..f18d92c 100755 --- a/script/installdotfiles +++ b/script/installdotfiles @@ -6,47 +6,49 @@ set -e # General -mkdir -p $HOME/dev -ln -sfn $HOME/dev/dotfiles/script $HOME/script +mkdir -p "$HOME/dev" +ln -sfn "$HOME/dev/dotfiles/script" "$HOME/script" # ZSH -mkdir -p $HOME/.config/zsh/functions +mkdir -p "$HOME/.config/zsh/functions" # TODO: ZSH on Mac appears to load zshenv from ZDOTDIR, not HOME. # Try to consolidate this. -if [ $(uname -s) = "Darwin" ]; then +if [ "$(uname -s)" = "Darwin" ]; then envpath="$HOME/.config/zsh/.zshenv" else envpath="$HOME/.zshenv" fi -ln -sfn $HOME/dev/dotfiles/zshenv "$envpath" -ln -sfn $HOME/dev/dotfiles/zshrc $HOME/.config/zsh/.zshrc +ln -sfn "$HOME/dev/dotfiles/zshenv" "$envpath" +ln -sfn "$HOME/dev/dotfiles/zshrc" "$HOME/.config/zsh/.zshrc" secretsfile="$HOME/.config/zsh/.zshsecrets" if [ ! -f "$secretsfile" ]; then - cp $HOME/dev/dotfiles/zshsecrets.example "$secretsfile" + cp "$HOME/dev/dotfiles/zshsecrets.example" "$secretsfile" fi # Tmux -ln -sfn $HOME/dev/dotfiles/tmux.conf $HOME/.tmux.conf +ln -sfn "$HOME/dev/dotfiles/tmux.conf" "$HOME/.tmux.conf" # Vim -mkdir -p $HOME/.vim/pack/git-plugins/{opt,start} -ln -sfn $HOME/dev/dotfiles/vimrc $HOME/.vimrc -ln -sfn $HOME/dev/dotfiles/vim/after $HOME/.vim/after +mkdir -p "$HOME/.vim/pack/git-plugins/{opt,start}" +ln -sfn "$HOME/dev/dotfiles/vimrc" "$HOME/.vimrc" +ln -sfn "$HOME/dev/dotfiles/vim/after" "$HOME/.vim/after" +ln -sfn "$HOME/dev/dotfiles/vim/after" "$HOME/.vim/queries" +ln -sfn "$HOME/dev/dotfiles/vim/after" "$HOME/.vim/lua" # Git -ln -sfn $HOME/dev/dotfiles/gitconfig $HOME/.gitconfig -mkdir -p $HOME/.config/git -ln -sfn $HOME/dev/dotfiles/gitignore $HOME/.config/git/ignore +ln -sfn "$HOME/dev/dotfiles/gitconfig" "$HOME/.gitconfig" +mkdir -p "$HOME/.config/git" +ln -sfn "$HOME/dev/dotfiles/gitignore" "$HOME/.config/git/ignore" # Alacritty -if [ $(uname -s) = "Darwin" ]; then +if [ "$(uname -s)" = "Darwin" ]; then alacrittyconfig="$HOME/dev/dotfiles/alacritty.macos.yml" else alacrittyconfig="$HOME/dev/dotfiles/alacritty.yml" fi -ln -sfn "$alacrittyconfig" $HOME/.config/alacritty.yml +ln -sfn "$alacrittyconfig" "$HOME/.config/alacritty.yml" echo "Done" diff --git a/script/installnvim b/script/installnvim index b79fdcf..9683b7e 100755 --- a/script/installnvim +++ b/script/installnvim @@ -3,18 +3,18 @@ # Clone or update nvim to $HOME/dev/neovim, build and install to $HOME/local set -e -mkdir -p $HOME/dev +mkdir -p "$HOME/dev" destdir=$HOME/dev/neovim -if [ -d $destdir ]; then +if [ -d "$destdir" ]; then echo "Updating nvim..." - cd $destdir + cd "$destdir" git pull --rebase else echo "Cloning nvim..." - cd $HOME/dev + cd "$HOME/dev" git clone -q https://github.com/neovim/neovim.git neovim - cd $destdir + cd "$destdir" fi -make CMAKE_BUILD_TYPE=Release CMAKE_INSTALL_PREFIX=$HOME/local +make CMAKE_BUILD_TYPE=Release CMAKE_INSTALL_PREFIX="$HOME/local" make install diff --git a/script/installpackages b/script/installpackages index 687a824..0e902a1 100755 --- a/script/installpackages +++ b/script/installpackages @@ -2,7 +2,7 @@ # # install packages for a new arch or manjaro installation. requires sudo -if [[ $euid > 0 ]]; then +if [[ $EUID -gt 0 ]]; then echo "requires administrative privileges" exit 1 fi @@ -21,4 +21,4 @@ pacman -S --needed --noconfirm base-devel \ syncthing \ ttf-ubuntu-font-family # ubuntu mono font for alacritty -sudo -u $SUDO_USER ./script/installpackagesnonroot +sudo -u "$SUDO_USER" ./script/installpackagesnonroot diff --git a/script/installpackagesnonroot b/script/installpackagesnonroot index 4bdd5c3..94902cc 100755 --- a/script/installpackagesnonroot +++ b/script/installpackagesnonroot @@ -4,7 +4,8 @@ # https://rustup.rs/ curl --proto '=https' --tlsv1.2 -ssf https://sh.rustup.rs | sh -s -- -y -source $HOME/.cargo/env +# shellcheck disable=SC1091 +source "$HOME/.cargo/env" # https://github.com/dandavison/delta#installation cargo install git-delta diff --git a/script/installvim b/script/installvim deleted file mode 100755 index 7ac37f2..0000000 --- a/script/installvim +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env bash -# -# Clone or update vim to $HOME/dev/vim, build and install to $HOME/local -set -e - -mkdir -p $HOME/dev -destdir=$HOME/dev/vim -if [ -d $destdir ]; then - echo "Updating vim..." - cd $destdir - git pull --rebase -else - echo "Cloning vim..." - cd $HOME/dev - git clone -q https://github.com/vim/vim.git vim -fi - -cd $destdir - -# TODO: https://stackoverflow.com/questions/53135863/macos-mojave-ruby-config-h-file-not-found -opts="--enable-luainterp --enable-python3interp --with-features=huge --enable-multibyte --enable-gui=gtk2" -if [ ! $(uname -s) = "Darwin" ]; then - opts="$opts --with-rubyinterp --with-x" -fi - -./configure --prefix=$HOME/local $opts -make -j6 -make install diff --git a/script/installvimplugins b/script/installvimplugins index 5dc977b..df1ade6 100755 --- a/script/installvimplugins +++ b/script/installvimplugins @@ -7,18 +7,18 @@ set -e # Note: not currently updated automatically by `updatevimplugins` url="https://raw.githubusercontent.com/junegunn/fzf/master/plugin/fzf.vim" echo "Fetching $url..." -mkdir -p $HOME/.vim/plugin -curl -sL -o $HOME/.vim/plugin/fzf.vim https://raw.githubusercontent.com/junegunn/fzf/master/plugin/fzf.vim +mkdir -p "$HOME/.vim/plugin" +curl -sL -o "$HOME/.vim/plugin/fzf.vim" https://raw.githubusercontent.com/junegunn/fzf/master/plugin/fzf.vim # Relies on vimrc containing lines e.g.: # packadd! rust.vim " https://github.com/rust-lang/rust.vim.git pluginhome=$HOME/.vim/pack/git-plugins/opt -mkdir -p $pluginhome -cd $pluginhome +mkdir -p "$pluginhome" +cd "$pluginhome" -grep packadd! $HOME/.config/nvim/init.vim | grep -o 'https.*$' | while read -r url ; do - dirname=$(basename $url .git) +grep packadd! "$HOME/.config/nvim/init.vim" | grep -o 'https.*$' | while read -r url ; do + dirname=$(basename "$url" .git) if [ -d "$dirname" ]; then echo "Exists: $dirname" else diff --git a/script/jira b/script/jira index 4cb8c0b..8a45c22 100755 --- a/script/jira +++ b/script/jira @@ -5,12 +5,12 @@ set -e if [ -z "$JIRADOMAIN" ]; then + # shellcheck disable=SC2016 echo 'set $JIRADOMAIN first' exit 1 fi -branchname="$(branchname)" -if [ ! $? -eq 0 ]; then +if ! branchname="$(branchname)"; then echo "branchname returned exit code: $?" exit 1 fi @@ -21,11 +21,10 @@ if ! echo "$branchname" | grep -q "/"; then fi ticket=$(echo "$branchname" | cut -d "/" -f1 | tr '[:lower:]' '[:upper:]') - url="$JIRADOMAIN/browse/$ticket" if [ "$1" == "-b" ]; then - if [ $(uname -s) = "Linux" ]; then + if [ "$(uname -s)" = "Linux" ]; then progname="xdg-open" else progname="open" # macOS @@ -35,4 +34,4 @@ if [ "$1" == "-b" ]; then exit $? fi -printf $url +printf "%s" "$url" diff --git a/script/ksc b/script/ksc index dd2e175..5e590d1 100755 --- a/script/ksc +++ b/script/ksc @@ -1,8 +1,8 @@ #!/usr/bin/env bash + set -euo pipefail -context=$(kubectl config get-contexts -o name | fzf) -if [ $? -ne 0 ]; then +if ! context=$(kubectl config get-contexts -o name | fzf); then exit $? fi diff --git a/script/myip b/script/myip index c67840a..42e93fe 100755 --- a/script/myip +++ b/script/myip @@ -7,11 +7,11 @@ set -e url='https://api.ipify.org?format=text' if [ "$1" = "-c" ]; then - if [ $(uname -s) = "Darwin" ]; then - curl -s $url | pbcopy + if [ "$(uname -s)" = "Darwin" ]; then + curl -s "$url" | pbcopy else - curl -s $url | xclip -i + curl -s "$url" | xclip -i fi else - curl -s $url + curl -s "$url" fi diff --git a/script/sysinfo b/script/sysinfo index ef0c147..1c40a7d 100755 --- a/script/sysinfo +++ b/script/sysinfo @@ -4,7 +4,7 @@ set -e -if [ $(uname -s) = "Darwin" ]; then +if [ "$(uname -s)" = "Darwin" ]; then uptime | grep -o "[0-9]\+\.[0-9]\+ [0-9]\+\.[0-9]\+ [0-9]\+\.[0-9]\+" else # Linux cut -d " " -f 1-3 /proc/loadavg diff --git a/script/tmuxsess b/script/tmuxsess index 5e22588..7ddc12c 100755 --- a/script/tmuxsess +++ b/script/tmuxsess @@ -9,17 +9,17 @@ set -e if [ -z "$1" ]; then cwd=$(pwd) - sessionname=$(basename $cwd) + sessionname=$(basename "$cwd") else sessionname="$1" fi -tmux_new_result=$(tmux new -d -s $sessionname 2>&1) || true +tmux_new_result=$(tmux new -d -s "$sessionname" 2>&1) || true exitcode=$? if echo "$tmux_new_result" | grep -q "duplicate session"; then echo "Session $sessionname already exists. Attaching..." - tmux new -d -A -s $sessionname + tmux new -d -A -s "$sessionname" exit 0 fi @@ -29,9 +29,9 @@ if [ $exitcode -ne 0 ]; then fi # TODO: fix sessionname containing full stop which are renamed by tmux -tmux rename-window -t $sessionname:1 cli -tmux new-window -t $sessionname -n vim zsh -ic nvim -tmux select-window -t $sessionname:1 +tmux rename-window -t "$sessionname:1" cli +tmux new-window -t "$sessionname" -n vim zsh -ic nvim +tmux select-window -t "$sessionname:1" # https://github.com/tmux/tmux/issues/2064 sleep 0.5 -tmux attach -t $sessionname +tmux attach -t "$sessionname" diff --git a/script/unstagebranch b/script/unstagebranch deleted file mode 100755 index 08e8b63..0000000 --- a/script/unstagebranch +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env bash -# -# Unstage a branch - -set -e - -branch=$(git rev-parse --abbrev-ref HEAD) - -if [ -z "$1" ]; then - basebranch="master" -else - basebranch="$1" -fi - -diff=$(git diff $basebranch...HEAD) -git co -q "$basebranch" -echo "$diff" | git apply -echo "Unstaged $branch against $basebranch successfully" -git diff --shortstat "HEAD...$branch" diff --git a/script/updateaurpackages b/script/updateaurpackages index b752caf..9331131 100755 --- a/script/updateaurpackages +++ b/script/updateaurpackages @@ -2,7 +2,9 @@ # # Update all AUR packages in $HOME/pkg -find $HOME/pkg -mindepth 1 -maxdepth 1 -type d -print0 | while read -d $'\0' pkgdir +set -euo pipefail + +find "$HOME/pkg" -mindepth 1 -maxdepth 1 -type d -print0 | while read -rd $'\0' pkgdir do cd "$pkgdir" pullres=$(git pull --rebase) diff --git a/script/updatedevenv b/script/updatedevenv index 548653d..ec8da7d 100755 --- a/script/updatedevenv +++ b/script/updatedevenv @@ -12,8 +12,10 @@ updatenvim updatevimplugins echo "Installing gopls..." -cd $HOME +cd "$HOME" go install golang.org/x/tools/gopls@latest go install honnef.co/go/tools/cmd/staticcheck@latest +# TODO: run installdotfiles? + echo "Done" diff --git a/script/updateinvidious b/script/updateinvidious deleted file mode 100755 index 157a300..0000000 --- a/script/updateinvidious +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/env bash -# -# Build and push Invidious -# -# TODO: remove Docker hub, push with SSH. - -set -e - -destdir=$HOME/dev/invidious -image=netfluxio/invidious:latest -remotehost=netflux - -if [ ! -d $destdir ]; then - echo "Cloning invidious..." - cd $HOME/dev - git clone -q --depth=1 https://github.com/iv-org/invidious.git invidious -else - echo "Updating invidious..." - cd $destdir - git pull --rebase -fi - -cd $destdir -docker build -t $image -f docker/Dockerfile . -docker push $image - -ssh $remotehost 'cd dev/netflux-internals && docker-compose pull invidious && docker-compose up -d --force-recreate --no-deps invidious' diff --git a/script/updatenetflux b/script/updatenetflux deleted file mode 100755 index 7c2546c..0000000 --- a/script/updatenetflux +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env bash -# -# updatenetflux - pull and restart containers on remote server - -set -e - -remotehost=netflux - -ssh $remotehost 'cd dev/netflux-internals && git pull --rebase && docker-compose down -v && docker-compose pull && docker-compose up -d --force-recreate' - -# invidious requires a local build, managed by a separate script. -updateinvidious diff --git a/script/updatevim b/script/updatevim deleted file mode 120000 index 7bf7931..0000000 --- a/script/updatevim +++ /dev/null @@ -1 +0,0 @@ -installvim \ No newline at end of file diff --git a/script/updatevimplugins b/script/updatevimplugins index 2099a17..3fb08c1 100755 --- a/script/updatevimplugins +++ b/script/updatevimplugins @@ -5,13 +5,13 @@ set -e pluginhome=$HOME/.vim/pack/git-plugins -cd $pluginhome +cd "$pluginhome" -find . -mindepth 2 -maxdepth 2 -type d -print0 | while read -d $'\0' pluginpath +find . -mindepth 2 -maxdepth 2 -type d -print0 | while read -rd $'\0' pluginpath do - cd $pluginpath - basename=$(basename $pluginpath) - printf "In $basename.. " + cd "$pluginpath" + basename=$(basename "$pluginpath") + printf "In %s.. " "$basename" git pull --rebase - cd $pluginhome + cd "$pluginhome" done diff --git a/script/uuidprint b/script/uuidprint index e576825..de6c2bb 100755 --- a/script/uuidprint +++ b/script/uuidprint @@ -2,4 +2,6 @@ # # uuidprint - generate and print a lower-case UUID v4 +set -e + uuidgen | tr '[:upper:]' '[:lower:]' | tr -d '\n' diff --git a/script/uuidyank b/script/uuidyank index f7a3c97..38fdac0 100755 --- a/script/uuidyank +++ b/script/uuidyank @@ -2,5 +2,7 @@ # # uuidyank - generate and copy a lower-case UUID v4 +set -e + # TODO: fix for Linux uuidprint | pbcopy diff --git a/script/wgdown b/script/wgdown index 842e8ac..4b1f911 100755 --- a/script/wgdown +++ b/script/wgdown @@ -4,7 +4,7 @@ set -e -if [[ $EUID > 0 ]]; then +if [[ $EUID -gt 0 ]]; then echo "requires administrative privileges" exit 1 fi diff --git a/script/wgup b/script/wgup index 670f73a..94e9f0c 100755 --- a/script/wgup +++ b/script/wgup @@ -4,7 +4,7 @@ set -e -if [[ $EUID > 0 ]]; then +if [[ $EUID -gt 0 ]]; then echo "requires administrative privileges" exit 1 fi