[misc] posix-compliant

This commit is contained in:
Klesh Wong 2020-11-02 12:08:18 +08:00
parent fba122e122
commit 757e2c547b
28 changed files with 209 additions and 212 deletions

View File

@ -1,7 +1,8 @@
#!/bin/bash #!/bin/sh
DIR=$(readlink -f $(dirname $0)) set -e
. $DIR/../env.sh DIR=$(readlink -f "$(dirname "$0")")
. "$DIR/../env.sh"
# let docker be able to build arm image on x86 # let docker be able to build arm image on x86

View File

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/sh
DIR=$(readlink -f $(dirname $0)) DIR=$(readlink -f "$(dirname "$0")")
. $DIR/../env.sh . "$DIR/../env.sh"
# install docker # install docker
@ -10,7 +10,7 @@ case "$PM" in
# snap docker will intefere native docker.io, must be dealt with # snap docker will intefere native docker.io, must be dealt with
sudo snap remove --purge docker sudo snap remove --purge docker
sudo apt install -y docker.io docker-compose sudo apt install -y docker.io docker-compose
! which pip3 && $ROOT/python/install.sh ! command -v pip3 && "$ROOT/python/install.sh"
sudo pip3 install docker-compose sudo pip3 install docker-compose
;; ;;
pacman) pacman)
@ -24,18 +24,18 @@ sudo systemctl start docker
# configuration # configuration
sudo usermod -aG docker $USER sudo usermod -aG docker "$USER"
# completion # completion
case "$DEFAULT_SHELL" in case "$DEFAULT_SHELL" in
$FISH) $FISH)
curl -sLo $HOME/.config/fish/completions/docker.fish --create-dirs \ curl -sLo "$HOME/.config/fish/completions/docker.fish" --create-dirs \
'https://github.com/docker/cli/raw/master/contrib/completion/fish/docker.fish' 'https://github.com/docker/cli/raw/master/contrib/completion/fish/docker.fish'
;; ;;
esac esac
# set mirror # set mirror
if in-china && [[ -d /etc/docker ]]; then if in_china && [ -d /etc/docker ]; then
if [ -f /etc/docker/daemon.json ]; then if [ -f /etc/docker/daemon.json ]; then
# backup # backup
[ ! -f /etc/docker/daemon.bak.json ] && \ [ ! -f /etc/docker/daemon.bak.json ] && \
@ -43,7 +43,7 @@ if in-china && [[ -d /etc/docker ]]; then
# read # read
dj=$(cat /etc/docker/daemon.json) dj=$(cat /etc/docker/daemon.json)
fi fi
[[ -z $dj ]] && dj='{}' [ -z "$dj" ] && dj='{}'
echo $dj | jq '. + {"registry-mirrors": ["https://izuhlbap.mirror.aliyuncs.com"]}' | \ echo $dj | jq '. + {"registry-mirrors": ["https://izuhlbap.mirror.aliyuncs.com"]}' | \
sudo tee /etc/docker/daemon.json sudo tee /etc/docker/daemon.json
sudo systemctl restart docker sudo systemctl restart docker

View File

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/sh
DIR=$(readlink -f $(dirname $0)) DIR=$(readlink -f "$(dirname "$0")")
. $DIR/../env.sh . "$DIR/../env.sh"
# install office utilities # install office utilities
@ -28,4 +28,4 @@ case "$PM" in
esac esac
# symlink configuration # symlink configuration
lnsf $DIR/config/zathura/zathurarc $XDG_CONFIG_HOME/zathura/zathurarc lnsf "$DIR/config/zathura/zathurarc" "$XDG_CONFIG_HOME/zathura/zathurarc"

View File

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/sh
DIR=$(readlink -f $(dirname $0)) DIR=$(readlink -f "$(dirname "$0")")
. $DIR/../env.sh . "$DIR/../env.sh"
# install docker # install docker
@ -17,8 +17,8 @@ esac
# completion for fish # completion for fish
case "$DEFAULT_SHELL" in case "$DEFAULT_SHELL" in
"$FISH") "$FISH")
[[ ! -f $HOME/.config/fish/completions/docker.fish ]] && \ [ ! -f "$HOME/.config/fish/completions/docker.fish" ] && \
curl -Lo $HOME/.config/fish/completions/docker.fish --create-dirs \ curl -Lo "$HOME/.config/fish/completions/docker.fish" --create-dirs \
'https://github.com/docker/cli/raw/master/contrib/completion/fish/docker.fish' 'https://github.com/docker/cli/raw/master/contrib/completion/fish/docker.fish'
fish -c "fisher add evanlucas/fish-kubectl-completions" fish -c "fisher add evanlucas/fish-kubectl-completions"
;; ;;

View File

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/sh
DIR=$(readlink -f $(dirname $0)) DIR=$(readlink -f "$(dirname "$0")")
. $DIR/../env.sh . "$DIR/../env.sh"
# install nextcloud # install nextcloud

View File

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/sh
DIR=$(readlink -f $(dirname $0)) DIR=$(readlink -f "$(dirname "$0")")
. $DIR/../env.sh . "$DIR/../env.sh"
# install nextcloud # install nextcloud

View File

@ -1,13 +1,14 @@
#!/bin/bash #!/bin/sh
DIR=$(readlink -f $(dirname $0)) DIR=$(readlink -f "$(dirname "$0")")
. $DIR/../env.sh . "$DIR/../env.sh"
read -p 'Please enter autologin username (empty to skip): ' username echo 'Please enter autologin username (empty to skip): '
read -r username
if [ -z "$username" ]; then if [ -z "$username" ]; then
echo skip autologin setup echo skip autologin setup
else else
sudo mkdir -p /etc/systemd/system/getty@tty1.service.d sudo mkdir -p /etc/systemd/system/getty@tty1.service.d
sed -r "s/USERNAME/$username/g" $DIR/systemd/getty1-override.conf | \ sed -r "s/USERNAME/$username/g" "$DIR/systemd/getty1-override.conf" | \
sudo tee /etc/systemd/system/getty@tty1.service.d/override.conf sudo tee /etc/systemd/system/getty@tty1.service.d/override.conf
fi fi

View File

@ -1,18 +1,18 @@
#!/bin/bash #!/bin/sh
DIR=$(readlink -f $(dirname $0)) DIR=$(readlink -f "$(dirname "$0")")
. $DIR/../env.sh . "$DIR/../env.sh"
$ROOT/python/install.sh "$ROOT/python/install.sh"
# install deep learning tools # install deep learning tools
case "$PM" in case "$PM" in
apt) apt)
# cuda # cuda
source /etc/lsb-release . /etc/lsb-release
if [ "$DISTRIB_RELEASE" = "18.04" ] && [ "$(uname -m)" = 'x86_64' ]; then if [ "$DISTRIB_RELEASE" = "18.04" ] && [ "$(uname -m)" = 'x86_64' ]; then
sudo apt install linux-headers-$(uname -r) sudo apt install "linux-headers-$(uname -r)"
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/cuda-ubuntu1804.pin wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/cuda-ubuntu1804.pin
sudo mv cuda-ubuntu1804.pin /etc/apt/preferences.d/cuda-repository-pin-600 sudo mv cuda-ubuntu1804.pin /etc/apt/preferences.d/cuda-repository-pin-600
sudo apt-key adv --fetch-keys \ sudo apt-key adv --fetch-keys \
@ -24,20 +24,20 @@ case "$PM" in
sudo apt install nvidia-cuda-toolkit sudo apt install nvidia-cuda-toolkit
else else
echo 'Unsupported release' echo 'Unsupported release'
exit -1 exit 1
fi fi
# nvidia docker # nvidia docker
distribution=$(. /etc/os-release;echo $ID$VERSION_ID) distribution="$ID$VERSION_ID"
curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add - curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add -
curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | \ curl -s -L "https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list" | \
sudo tee /etc/apt/sources.list.d/nvidia-docker.list sudo tee /etc/apt/sources.list.d/nvidia-docker.list
sudo apt update sudo apt update
sudo apt install -y nvidia-docker2 sudo apt install -y nvidia-docker2
;; ;;
pacman) pacman)
echo TODO echo TODO
exit -1 exit 1
;; ;;
esac esac

View File

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/sh
DIR=$(readlink -f $(dirname $0)) DIR=$(readlink -f "$(dirname "$0")")
. $DIR/../env.sh . "$DIR/../env.sh"
# install nvim # install nvim
case "$PM" in case "$PM" in
@ -14,5 +14,5 @@ case "$PM" in
esac esac
# symlink configuration # symlink configuration
lnsf $DIR/config/dunstrc $XDG_CONFIG_HOME/dunst/dunstrc lnsf "$DIR/config/dunstrc" "$XDG_CONFIG_HOME/dunst/dunstrc"
lnsf $DIR/config/launch.sh $XDG_CONFIG_HOME/dunst/launch.sh lnsf "$DIR/config/launch.sh" "$XDG_CONFIG_HOME/dunst/launch.sh"

53
env.sh
View File

@ -1,61 +1,56 @@
#!/bin/bash #!/bin/sh
set -e set -e
ROOT=$(readlink -f $(dirname "${BASH_SOURCE[0]}")) ROOT=$(readlink -f "$(dirname "$0")")
PM=n/a PM=n/a
DEFAULT_SHELL=$(getent passwd $USER | cut -d: -f7)
FISH=$(which fish)
XDG_CONFIG_HOME=${XDG_CONFIG_HOME-"$HOME/.config"} XDG_CONFIG_HOME=${XDG_CONFIG_HOME-"$HOME/.config"}
echo "dotfiles path: $ROOT"
if which pacman > /dev/null; then if command -v pacman > /dev/null; then
PM=pacman PM=pacman
elif which apt > /dev/null; then elif command -v apt > /dev/null; then
PM=apt PM=apt
fi fi
if [ "$PM" = "n/a" ]; then if [ "$PM" = "n/a" ]; then
echo "Unsupported Package Manager" echo "Unsupported Package Manager"
exit -1 exit 1
fi fi
in-china () { in_china () {
if [ -z "$IS_CHINA" ]; then if [ -z "$IS_CHINA" ]; then
IS_CHINA=no IS_CHINA=no
if curl -q myip.ipip.net | grep '中国' > /dev/null; then if curl -q myip.ipip.net | grep '中国' > /dev/null; then
IS_CHINA=yes IS_CHINA=yes
fi fi
fi fi
[ "$IS_CHINA" = "no" ] && return -1 [ "$IS_CHINA" = "no" ] && return 1
return 0 return 0
} }
lnsf () { lnsf () {
[ "$#" -ne 2 ] && echo "lnsf <target> <symlink>" && return -1 [ "$#" -ne 2 ] && echo "lnsf <target> <symlink>" && return 1
local TARGET=$(readlink -f $1) TARGET=$(readlink -f "$1")
local SYMLNK=$2 SYMLNK=$2
[ -z "$TARGET" ] && echo "$1 not exists" && return -1 [ -z "$TARGET" ] && echo "$1 not exists" && return 1
local SYMDIR=$(dirname $SYMLNK) SYMDIR=$(dirname "$SYMLNK")
if [[ -n $SYMDIR && -L $SYMDIR ]]; then if [ -n "$SYMDIR" && -L "$SYMDIR" ]; then
rm -rf $SYMDIR rm -rf "$SYMDIR"
fi fi
mkdir -p $SYMDIR mkdir -p "$SYMDIR"
[ ! -L $SYMLNK ] && rm -rf $SYMLNK [ ! -L "$SYMLNK" ] && rm -rf "$SYMLNK"
ln -sf $TARGET $SYMLNK ln -sf "$TARGET" "$SYMLNK"
} }
fish-is-default-shell () { has_bluetooth () {
[ "$DEFAULT_SHELL" = "$FISH" ]
}
has-bluetooth () {
dmesg | grep -i bluetooth dmesg | grep -i bluetooth
} }
eqv () { eqv () {
local VERSION_PATH=$1 VERSION_PATH=$1
local VERSION=$2 VERSION=$2
[ ! -f $VERSION_PATH ] && return -1 [ ! -f "$VERSION_PATH" ] && return 1
local VERSION2=$(cat "$VERSION_PATH") VERSION2="$(cat "$VERSION_PATH")"
[ "$VERSION" = "$VERSION2" ] [ "$VERSION" = "$VERSION2" ]
} }
@ -78,7 +73,7 @@ case "$PM" in
curl wget \ curl wget \
man sudo man sudo
# install yay # install yay
if ! which yay; then if ! command -v yay; then
git clone --depth 1 https://aur.archlinux.org/yay.git /tmp/yay git clone --depth 1 https://aur.archlinux.org/yay.git /tmp/yay
cd /tmp/yay cd /tmp/yay
makepkg -si makepkg -si

View File

@ -1,25 +1,23 @@
#!/bin/bash #!/bin/sh
DIR=$(readlink -f $(dirname $0)) DIR=$(readlink -f "$(dirname "$0")")
. $DIR/../env.sh . "$DIR/../env.sh"
# install fish shell # install fish shell
echo Installing fish shell echo Installing fish shell
case "$PM" in case "$PM" in
apt) apt)
! which pip3 && $ROOT/python/install.sh ! command -v pip3 && "$ROOT/python/install.sh"
sudo add-apt-repository ppa:fish-shell/release-3 -y sudo add-apt-repository ppa:fish-shell/release-3 -y
sudo apt update sudo apt update
sudo apt install fish libnotify-bin xdotool silversearcher-ag dash -y sudo apt install fish libnotify-bin xdotool silversearcher-ag dash -y
if apt show fzf &>/dev/null; then if apt show fzf 2>/dev/null; then
sudo apt install fzf sudo apt install -y fzf
elif ! which fzf &>/dev/null; then
git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf
~/.fzf/install ~/.fzf/install
fi fi
;; ;;
pacman) pacman)
! which pip && $ROOT/python/install.sh
sudo pacman -S --needed --needed fish xdotool fzf the_silver_searcher dash sudo pacman -S --needed --needed fish xdotool fzf the_silver_searcher dash
# prevent bash upgradation relink /bin/sh # prevent bash upgradation relink /bin/sh
sudo mkdir -p /etc/pacman.d/hooks sudo mkdir -p /etc/pacman.d/hooks
@ -40,18 +38,18 @@ case "$PM" in
esac esac
# use dash as default shell because it much faster and will be used vim-fugitive, # use dash as default shell because it much faster and will be used vim-fugitive,
# which leads to a much faster responsive speed # leads to a much faster responsive speed
sudo /usr/bin/ln -sfT dash /usr/bin/sh sudo /usr/bin/ln -sfT dash /usr/bin/sh
chsh -s /bin/sh chsh -s /bin/sh
# symlink config # symlink config
[ -L $XDG_CONFIG_HOME/fish ] && rm -rf $XDG_CONFIG_HOME/fish [ -L "$XDG_CONFIG_HOME/fish" ] && rm -rf "$XDG_CONFIG_HOME/fish"
lnsf $DIR/config/config.fish $XDG_CONFIG_HOME/fish/config.fish lnsf "$DIR/config/config.fish" "$XDG_CONFIG_HOME/fish/config.fish"
lnsf $DIR/config/functions/fish_prompt.fish $XDG_CONFIG_HOME/fish/functions/fish_prompt.fish lnsf "$DIR/config/functions/fish_prompt.fish" "$XDG_CONFIG_HOME/fish/functions/fish_prompt.fish"
lnsf $DIR/config/functions/fish_right_prompt.fish $XDG_CONFIG_HOME/fish/functions/fish_right_prompt.fish lnsf "$DIR/config/functions/fish_right_prompt.fish" "$XDG_CONFIG_HOME/fish/functions/fish_right_prompt.fish"
lnsf $DIR/config/functions/fisher.fish $XDG_CONFIG_HOME/fish/functions/fisher.fish lnsf "$DIR/config/functions/fisher.fish" "$XDG_CONFIG_HOME/fish/functions/fisher.fish"
# install plugins # install plugins
fish -c "fisher add jethrokuan/fzf" fish -c "fisher add jethrokuan/fzf"

View File

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/sh
DIR=$(readlink -f $(dirname $0)) DIR=$(readlink -f "$(dirname "$0")")
. $DIR/../env.sh . "$DIR/../env.sh"
# install basic gui stuff, including fonts/system utilties/keyring etc # install basic gui stuff, including fonts/system utilties/keyring etc
case "$PM" in case "$PM" in
@ -18,7 +18,7 @@ case "$PM" in
sudo apt install \ sudo apt install \
network-manager network-manager-gnome network-manager network-manager-gnome
# bluetooth # bluetooth
if has-bluetooth; then if has_bluetooth; then
sudo apt install \ sudo apt install \
bluez bluez-tools blueman pulseaudio-module-bluetooth bluez bluez-tools blueman pulseaudio-module-bluetooth
sudo systemctl enable bluetooth sudo systemctl enable bluetooth
@ -41,10 +41,9 @@ case "$PM" in
# https://code.google.com/p/chromium/issues/detail?id=233851 # https://code.google.com/p/chromium/issues/detail?id=233851
# use debian package instead # use debian package instead
DEB_PKG_NAME=fonts-wqy-microhei_0.2.0-beta-3_all.deb DEB_PKG_NAME=fonts-wqy-microhei_0.2.0-beta-3_all.deb
PAC_PKG_NAME=fonts-wqy-microhei_0.2.0-beta-3_all.pkg [ ! -f "/tmp/$DEB_PKG_NAME" ] && \
[[ ! -f /tmp/$DEB_PKG_NAME ]] && \
wget http://mirrors.163.com/debian/pool/main/f/fonts-wqy-microhei/$DEB_PKG_NAME -O /tmp/$DEB_PKG_NAME wget http://mirrors.163.com/debian/pool/main/f/fonts-wqy-microhei/$DEB_PKG_NAME -O /tmp/$DEB_PKG_NAME
ar p /tmp/$DEB_PKG_NAME data.tar.xz | sudo tar Jxv -C / ar p "/tmp/$DEB_PKG_NAME" data.tar.xz | sudo tar Jxv -C /
# install symbola for plain emojis(no-color) for st # install symbola for plain emojis(no-color) for st
! fc-list | grep -qi symbola && yay -S --needed ttf-symbola-free ! fc-list | grep -qi symbola && yay -S --needed ttf-symbola-free
# clipboard # clipboard
@ -57,7 +56,7 @@ case "$PM" in
sudo pacman -S --needed \ sudo pacman -S --needed \
networkmanager network-manager-applet networkmanager network-manager-applet
# bluetooth # bluetooth
if has-bluetooth; then if has_bluetooth; then
sudo pacman -S --needed \ sudo pacman -S --needed \
bluez bluez-utils blueman pulseaudio-bluetooth xorg-xbacklight bluez bluez-utils blueman pulseaudio-bluetooth xorg-xbacklight
sudo systemctl enable bluetooth sudo systemctl enable bluetooth
@ -73,7 +72,7 @@ esac
# install hermit nerd font # install hermit nerd font
install-nerdfont () { install_nerdfont () {
grep -F "$*" /usr/local/share/fonts/nerdfont && return grep -F "$*" /usr/local/share/fonts/nerdfont && return
ORIGIN_NAME=$1 ORIGIN_NAME=$1
PATCHED_PAT=$2 PATCHED_PAT=$2
@ -81,22 +80,21 @@ install-nerdfont () {
NAME=$ORIGIN_NAME-$VERSION.zip NAME=$ORIGIN_NAME-$VERSION.zip
LOCAL_REPO_PATH=/tmp/nerd-font/$ORIGIN_NAME LOCAL_REPO_PATH=/tmp/nerd-font/$ORIGIN_NAME
# shortcircuit if font already in system # shortcircuit if font already in system
fc-list | grep -F $0 | grep -i nerd && return fc-list | grep -F "$PATCHED_PAT" | grep -i nerd && return
# clone single branch from gitee # clone single branch from gitee
git clone --single-branch --branch $ORIGIN_NAME --depth 1 \ git clone --single-branch --branch "$ORIGIN_NAME" --depth 1 \
https://gitee.com/klesh/nerd-fonts.git \ https://gitee.com/klesh/nerd-fonts.git \
$LOCAL_REPO_PATH "$LOCAL_REPO_PATH"
sudo 7z x -x!'*Windows*' -aoa $LOCAL_REPO_PATH/$NAME -o/usr/local/share/fonts sudo 7z x -x!'*Windows*' -aoa "$LOCAL_REPO_PATH/$NAME" -o/usr/local/share/fonts
sudo chmod +rx /usr/local/share/fonts sudo chmod +rx /usr/local/share/fonts
echo "$*" | sudo tee -a /usr/local/share/fonts/nerdfont echo "$*" | sudo tee -a /usr/local/share/fonts/nerdfont
echo $LOCAL_REPO_PATH rm -rf "$LOCAL_REPO_PATH"
rm -rf $LOCAL_REPO_PATH
} }
#install-nerdfont Hermit Hurmit v2.1.0 #install_nerdfont Hermit Hurmit v2.1.0
install-nerdfont Agave agave v2.1.0 install_nerdfont Agave agave v2.1.0
#install-nerdfont CascadiaCode Caskaydia v2.1.0 #install_nerdfont CascadiaCode Caskaydia v2.1.0
#install-nerdfont DaddyTimeMono DaddyTimeMono v2.1.0 #install_nerdfont DaddyTimeMono DaddyTimeMono v2.1.0
# start network # start network
sudo systemctl enable NetworkManager sudo systemctl enable NetworkManager
@ -106,5 +104,5 @@ sudo systemctl start NetworkManager
sudo ln -sf /etc/fonts/conf.avail/70-no-bitmaps.conf /etc/fonts/conf.d sudo ln -sf /etc/fonts/conf.avail/70-no-bitmaps.conf /etc/fonts/conf.d
sudo ln -sf /etc/fonts/conf.avail/10-sub-pixel-rgb.conf /etc/fonts/conf.d sudo ln -sf /etc/fonts/conf.avail/10-sub-pixel-rgb.conf /etc/fonts/conf.d
sudo ln -sf /etc/fonts/conf.avail/11-lcdfilter-default.conf /etc/fonts/conf.d sudo ln -sf /etc/fonts/conf.avail/11-lcdfilter-default.conf /etc/fonts/conf.d
sudo cp $DIR/freetype2.sh /etc/profile.d/freetype2.sh sudo cp "$DIR/freetype2.sh" "/etc/profile.d/freetype2.sh"
sudo cp $DIR/local.conf /etc/fonts/local.conf sudo cp "$DIR/local.conf" "/etc/fonts/local.conf"

View File

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/sh
DIR=$(readlink -f $(dirname $0)) DIR=$(readlink -f "$(dirname "$0")")
. $DIR/../env.sh . "$DIR/../env.sh"
# install sshd # install sshd
case "$PM" in case "$PM" in

View File

@ -1,7 +1,8 @@
#!/bin/bash #!/bin/sh
DIR=$(readlink -f $(dirname $0)) set -e
. $DIR/../env.sh DIR=$(readlink -f "$(dirname "$0")")
. "$DIR/../env.sh"
# for better looking # for better looking
case "$PM" in case "$PM" in

View File

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/sh
DIR=$(readlink -f $(dirname $0)) DIR=$(readlink -f "$(dirname "$0")")
. $DIR/../env.sh . "$DIR/../env.sh"
# tips # tips
# 1. to relocate default pool # 1. to relocate default pool
@ -26,4 +26,4 @@ case "$PM" in
esac esac
# configuration # configuration
sudo usermod -aG libvirt $USER sudo usermod -aG libvirt "$USER"

View File

@ -1,21 +1,21 @@
#!/bin/bash #!/bin/sh
DIR=$(readlink -f $(dirname $0)) DIR=$(readlink -f "$(dirname "$0")")
. $DIR/../env.sh . "$DIR/../env.sh"
# install specific version # install specific version
if [[ -n $1 ]]; then if [ -n "$1" ]; then
if which node &>/dev/null && [[ "$1" != "$(node -v)" ]]; then if command -v node 1>/dev/null 2>&1 && [ "$1" != "$(node -v)" ]; then
NODE_URL=https://nodejs.org/dist NODE_URL=https://nodejs.org/dist
in-china && NODE_URL=https://npm.taobao.org/mirrors/node in_china && NODE_URL=https://npm.taobao.org/mirrors/node
if [[ $1 == 'ls' ]]; then if [ "$1" = 'ls' ]; then
curl -s $NODE_URL/index.json | jq '.[] | "\(.version) \(if .lts then "(lts)" else "" end)"' -r | less curl -s $NODE_URL/index.json | jq '.[] | "\(.version) \(if .lts then "(lts)" else "" end)"' -r | less
exit exit
else else
FN=node-$1-linux-x64.tar.gz FN=node-$1-linux-x64.tar.gz
wget -O /tmp/$FN $NODE_URL/$1/$FN wget -O "/tmp/$FN" "$NODE_URL/$1/$FN"
sudo tar zxvf /tmp/$FN --strip 1 -C /usr/local/ sudo tar zxvf "/tmp/$FN" --strip 1 -C /usr/local/
rm /tmp/$FN rm "/tmp/$FN"
fi fi
fi fi
else else
@ -32,7 +32,7 @@ fi
# install nvm # install nvm
if which fish 2>/dev/null; then if command -v fish 2>/dev/null; then
fish -c "fisher add jorgebucaran/nvm.fish" fish -c "fisher add jorgebucaran/nvm.fish"
else else
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
@ -40,7 +40,7 @@ fi
# config mirrors for CHINA # config mirrors for CHINA
if in-china; then if in_china; then
sudo npm install cnpm -g --registry=https://r.npm.taobao.org sudo npm install cnpm -g --registry=https://r.npm.taobao.org
yarnpkg config set registry https://registry.npm.taobao.org --global && \ yarnpkg config set registry https://registry.npm.taobao.org --global && \
yarnpkg config set disturl https://npm.taobao.org/dist --global && \ yarnpkg config set disturl https://npm.taobao.org/dist --global && \

View File

@ -2,5 +2,8 @@
"npm.binPath": "yarnpkg", "npm.binPath": "yarnpkg",
"python.linting.enable": true, "python.linting.enable": true,
"python.linting.flake8Enabled": true, "python.linting.flake8Enabled": true,
"python.linting.pylintEnabled": false "python.linting.pylintEnabled": false,
"diagnostic-languageserver.filetypes": {
"sh": ["shellcheck", "-e", "SC1090"]
}
} }

View File

@ -1,10 +1,10 @@
#!/bin/bash #!/bin/sh
DIR=$(readlink -f $(dirname $0)) DIR=$(readlink -f "$(dirname "$0")")
. $DIR/../env.sh . "$DIR/../env.sh"
# check dependencies # check dependencies
! which yarnpkg && $ROOT/nodejs/install.sh ! command -v yarnpkg && "$ROOT/nodejs/install.sh"
# install nvim # install nvim
case "$PM" in case "$PM" in
@ -19,6 +19,6 @@ case "$PM" in
esac esac
# symlink configuration # symlink configuration
lnsf $DIR/config/init.vim $XDG_CONFIG_HOME/nvim/init.vim lnsf "$DIR/config/init.vim" "$XDG_CONFIG_HOME/nvim/init.vim"
lnsf $DIR/config/coc-settings.json $XDG_CONFIG_HOME/nvim/coc-settings.json lnsf "$DIR/config/coc-settings.json" "$XDG_CONFIG_HOME/nvim/coc-settings.json"
lnsf $DIR/config/init.vim ~/.vimrc lnsf "$DIR/config/init.vim" ~/.vimrc

View File

@ -1,10 +1,10 @@
#!/bin/bash #!/bin/sh
DIR=$(readlink -f $(dirname $0)) DIR=$(readlink -f "$(dirname "$0")")
. $DIR/../env.sh . "$DIR/../env.sh"
! in-china && echo 'Skip mirrors configuration' && exit ! in_china && echo 'Skip mirrors configuration' && exit
# setup package mirror for CHINA # setup package mirror for CHINA
case "$PM" in case "$PM" in
@ -18,7 +18,7 @@ case "$PM" in
;; ;;
pacman) pacman)
echo TODO echo TODO
exit -1 exit 1
;; ;;
esac esac

View File

@ -1,4 +1,4 @@
#!/bin/bash #!/bin/sh
sudo systemctl disable systemd-networkd-wait-online sudo systemctl disable systemd-networkd-wait-online

View File

@ -1,16 +1,15 @@
#!/bin/bash #!/bin/sh
DIR=$(readlink -f $(dirname $0)) set -e
. $DIR/../env.sh DIR=$(readlink -f "$(dirname "$0")")
. "$DIR/../env.sh"
PICOM_VER=v8.1
# install ranger # install ranger
case "$PM" in case "$PM" in
apt) apt)
# install build tools # install build tools
! which pip3 && $ROOT/python/install.sh ! command -v pip3 && "$ROOT/python/install.sh"
sudo pip3 install meson sudo pip3 install meson
# install dependencies # install dependencies
sudo apt install -y ninja-build libxext-dev libxcb1-dev libxcb-damage0-dev libxcb-xfixes0-dev libxcb-shape0-dev libxcb-render-util0-dev libxcb-render0-dev libxcb-randr0-dev libxcb-composite0-dev libxcb-image0-dev libxcb-present-dev libxcb-xinerama0-dev libxcb-glx0-dev libpixman-1-dev libdbus-1-dev libconfig-dev libgl1-mesa-dev libpcre3-dev libevdev-dev uthash-dev libev-dev libx11-xcb-dev sudo apt install -y ninja-build libxext-dev libxcb1-dev libxcb-damage0-dev libxcb-xfixes0-dev libxcb-shape0-dev libxcb-render-util0-dev libxcb-render0-dev libxcb-randr0-dev libxcb-composite0-dev libxcb-image0-dev libxcb-present-dev libxcb-xinerama0-dev libxcb-glx0-dev libpixman-1-dev libdbus-1-dev libconfig-dev libgl1-mesa-dev libpcre3-dev libevdev-dev uthash-dev libev-dev libx11-xcb-dev
@ -29,16 +28,16 @@ if [ "$VERSION" = "next" ] || ! eqv "$VERSION_PATH" "$VERSION"; then
curl "https://github.com/yshui/picom/archive/$VERSION.zip" -Lo /tmp/picom-$VERSION.zip curl "https://github.com/yshui/picom/archive/$VERSION.zip" -Lo /tmp/picom-$VERSION.zip
unzip /tmp/picom-$VERSION.zip -d /tmp unzip /tmp/picom-$VERSION.zip -d /tmp
FD=$(unzip -l /tmp/picom-$VERSION.zip | awk 'NR==5{print $4}') FD=$(unzip -l /tmp/picom-$VERSION.zip | awk 'NR==5{print $4}')
pushd /tmp/$FD cd "/tmp/$FD"
meson --buildtype=release . build meson --buildtype=release . build
sudo ninja -C build install sudo ninja -C build install
popd cd -
mkdir -p $(dirname $VERSION_PATH) mkdir -p "$(dirname "$VERSION_PATH")"
echo "$VERSION" > "$VERSION_PATH" echo "$VERSION" > "$VERSION_PATH"
sudo rm -rf /tmp/picom-$VERSION* sudo rm -rf /tmp/picom-$VERSION*
fi fi
# configuration # configuration
lnsf $DIR/config/launch.sh $XDG_CONFIG_HOME/picom/launch.sh lnsf "$DIR/config/launch.sh" "$XDG_CONFIG_HOME/picom/launch.sh"
lnsf $DIR/config/toggle.sh $XDG_CONFIG_HOME/picom/toggle.sh lnsf "$DIR/config/toggle.sh" "$XDG_CONFIG_HOME/picom/toggle.sh"
lnsf $DIR/config/picom.conf $XDG_CONFIG_HOME/picom/picom.conf lnsf "$DIR/config/picom.conf" "$XDG_CONFIG_HOME/picom/picom.conf"

View File

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/sh
DIR=$(readlink -f $(dirname $0)) DIR=$(readlink -f "$(dirname "$0")")
. $DIR/../env.sh . "$DIR/../env.sh"
# install music and video player # install music and video player
@ -15,16 +15,16 @@ case "$PM" in
esac esac
# symlink configuration # symlink configuration
lnsf $DIR/config/mpd/mpd.conf $XDG_CONFIG_HOME/mpd/mpd.conf lnsf "$DIR/config/mpd/mpd.conf" "$XDG_CONFIG_HOME/mpd/mpd.conf"
lnsf $DIR/config/mpv/mpv.conf $XDG_CONFIG_HOME/mpv/mpv.conf lnsf "$DIR/config/mpv/mpv.conf" "$XDG_CONFIG_HOME/mpv/mpv.conf"
lnsf $DIR/config/mpv/scripts/organize.lua $XDG_CONFIG_HOME/mpv/scripts/organize.lua lnsf "$DIR/config/mpv/scripts/organize.lua" "$XDG_CONFIG_HOME/mpv/scripts/organize.lua"
lnsf $DIR/config/ncmpcpp/bindings $XDG_CONFIG_HOME/ncmpcpp/bindings lnsf "$DIR/config/ncmpcpp/bindings" "$XDG_CONFIG_HOME/ncmpcpp/bindings"
lnsf $DIR/config/ncmpcpp/config $XDG_CONFIG_HOME/ncmpcpp/config lnsf "$DIR/config/ncmpcpp/config" "$XDG_CONFIG_HOME/ncmpcpp/config"
# prevent system-wide mpd # prevent system-wide mpd
sudo systemctl disable mpd sudo systemctl disable mpd
sudo systemctl stop mpd sudo systemctl stop mpd
mkdir -p $HOME/.mpd/playlists mkdir -p "$HOME/.mpd/playlists"
# enable for current user # enable for current user
systemctl --user enable mpd systemctl --user enable mpd

View File

@ -1,14 +1,14 @@
#!/bin/bash #!/bin/sh
DIR=$(readlink -f $(dirname $0)) DIR=$(readlink -f "$(dirname "$0")")
. $DIR/../env.sh . "$DIR/../env.sh"
# config pip mirror for CHINA # config pip mirror for CHINA
if in-china; then if in_china; then
lnsf $DIR/pip.conf ~/.pip/pip.conf lnsf "$DIR/pip.conf" ~/.pip/pip.conf
if sudo [ ! -f /root/.pip/pip.conf ]; then if sudo [ ! -f /root/.pip/pip.conf ]; then
sudo mkdir -p /root/.pip sudo mkdir -p /root/.pip
sudo cp $DIR/pip.conf /root/.pip/pip.conf sudo cp "$DIR/pip.conf" /root/.pip/pip.conf
fi fi
fi fi
@ -16,15 +16,15 @@ fi
case "$PM" in case "$PM" in
apt) apt)
sudo apt install python3 python3-pip python-is-python3 sudo apt install python3 python3-pip python-is-python3
which fish 2>/dev/null && sudo pip3 install virtualfish command -v fish 2>/dev/null && sudo pip3 install virtualfish
;; ;;
pacman) pacman)
sudo pacman -S --needed python python-pip sudo pacman -S --needed python python-pip
which fish 2>/dev/null && sudo pip install virtualfish command -v fish 2>/dev/null && sudo pip install virtualfish
;; ;;
esac esac
# enable auto_activation plugin for virtualfish # enable auto_activation plugin for virtualfish
which fish 2>/dev/null && fish -c "yes | vf install && vf addplugins auto_activation" command -v fish 2>/dev/null && fish -c "yes | vf install && vf addplugins auto_activation"

View File

@ -1,4 +1,4 @@
#!/bin/bash #!/bin/sh
set -e set -e

View File

@ -1,14 +1,14 @@
#!/bin/bash #!/bin/sh
DIR=$(readlink -f $(dirname $0)) DIR=$(readlink -f "$(dirname "$0")")
. $DIR/../env.sh . "$DIR/../env.sh"
# install ranger # install ranger
case "$PM" in case "$PM" in
apt) apt)
# atool/p7zip-full for archive previewing/extracting etc # atool/p7zip-full for archive previewing/extracting etc
sudo apt install -y atool p7zip-full unrar highlight sudo apt install -y atool p7zip-full unrar highlight
! which pip3 && $ROOT/python/install.sh ! command -v pip3 && "$ROOT/python/install.sh"
sudo pip3 install ranger-fm ueberzug sudo pip3 install ranger-fm ueberzug
;; ;;
pacman) pacman)
@ -18,9 +18,9 @@ case "$PM" in
esac esac
# linking configuration files # linking configuration files
lnsf $DIR/config/commands.py $XDG_CONFIG_HOME/ranger/commands.py lnsf "$DIR/config/commands.py" "$XDG_CONFIG_HOME/ranger/commands.py"
lnsf $DIR/config/rc.conf $XDG_CONFIG_HOME/ranger/rc.conf lnsf "$DIR/config/rc.conf" "$XDG_CONFIG_HOME/ranger/rc.conf"
lnsf $DIR/config/scope.sh $XDG_CONFIG_HOME/ranger/scope.sh lnsf "$DIR/config/scope.sh" "$XDG_CONFIG_HOME/ranger/scope.sh"
# install devicons # install devicons
git clone --depth 1 https://github.com/alexanderjeurissen/ranger_devicons ~/.config/ranger/plugins/ranger_devicons git clone --depth 1 https://github.com/alexanderjeurissen/ranger_devicons ~/.config/ranger/plugins/ranger_devicons

View File

@ -1,12 +1,12 @@
#!/bin/bash #!/bin/sh
DIR=$(readlink -f $(dirname $0)) DIR=$(readlink -f "$(dirname "$0")")
. $DIR/../env.sh . "$DIR/../env.sh"
$ROOT/fish/install.sh "$ROOT/fish/install.sh"
$ROOT/gui/install.sh "$ROOT/gui/install.sh"
$ROOT/picom/install.sh "$ROOT/picom/install.sh"
$ROOT/dunst/install.sh "$ROOT/dunst/install.sh"
# install dependencies # install dependencies
case "$PM" in case "$PM" in
@ -86,8 +86,8 @@ EOT
# config dwm # config dwm
[[ -L $XDG_CONFIG_HOME/dwm/autostart ]] && rm $XDG_CONFIG_HOME/dwm/autostart [ -L "$XDG_CONFIG_HOME/dwm/autostart" ] && rm "$XDG_CONFIG_HOME/dwm/autostart"
mkdir -p $XDG_CONFIG_HOME/dwm mkdir -p "$XDG_CONFIG_HOME/dwm"
cp $DIR/config/dwm/autostart $XDG_CONFIG_HOME/dwm/autostart cp "$DIR/config/dwm/autostart" "$XDG_CONFIG_HOME/dwm/autostart"
lnsf $DIR/config/dwm/statusbar $XDG_CONFIG_HOME/dwm/statusbar lnsf "$DIR/config/dwm/statusbar" "$XDG_CONFIG_HOME/dwm/statusbar"
lnsf $DIR/config/autorandr/postswitch $XDG_CONFIG_HOME/autorandr/postswitch lnsf "$DIR/config/autorandr/postswitch" "$XDG_CONFIG_HOME/autorandr/postswitch"

View File

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/sh
DIR=$(readlink -f $(dirname $0)) DIR=$(readlink -f "$(dirname "$0")")
. $DIR/../env.sh . "$DIR/../env.sh"
# install ranger # install ranger
case "$PM" in case "$PM" in
@ -16,4 +16,4 @@ case "$PM" in
esac esac
# symlink configuration # symlink configuration
lnsf $DIR/Thunar/uca.xml $XDG_CONFIG_HOME/Thunar/uca.xml lnsf "$DIR/Thunar/uca.xml" "$XDG_CONFIG_HOME/Thunar/uca.xml"

View File

@ -1,28 +1,29 @@
#!/bin/bash #!/bin/sh
DIR=$(readlink -f $(dirname $0)) set -e
. $DIR/../env.sh DIR=$(readlink -f "$(dirname "$0")")
. "$DIR/../env.sh"
TMUX_VER=3.1b TMUX_VER=3.1b
# install ranger # install ranger
case "$PM" in case "$PM" in
apt) apt)
if which tmux &>/dev/null && [ "$(tmux -V)" != "tmux $TMUX_VER" ]; then if command -v tmux &>/dev/null && [ "$(tmux -V)" != "tmux $TMUX_VER" ]; then
sudo apt install libevent-dev libncurses5-dev bison autoconf bc -y sudo apt install libevent-dev libncurses5-dev bison autoconf bc -y
TMUX_SRC_URL=https://github.com/tmux/tmux/releases/download/$TMUX_VER/tmux-$TMUX_VER.tar.gz TMUX_SRC_URL=https://github.com/tmux/tmux/releases/download/$TMUX_VER/tmux-$TMUX_VER.tar.gz
if in-china; then if in_china; then
TMUX_SRC_URL=https://gitee.com/klesh/tmux/repository/archive/$TMUX_VER?format=tar.gz TMUX_SRC_URL="https://gitee.com/klesh/tmux/repository/archive/$TMUX_VER?format=tar.gz"
fi fi
[ ! -f /tmp/tmux.tar.gz ] && curl -L $TMUX_SRC_URL -o /tmp/tmux.tar.gz [ ! -f /tmp/tmux.tar.gz ] && curl -L "$TMUX_SRC_URL" -o /tmp/tmux.tar.gz
rm -rf /tmp/tmux rm -rf /tmp/tmux
mkdir -p /tmp/tmux mkdir -p /tmp/tmux
tar zxvf /tmp/tmux.tar.gz -C /tmp/tmux --strip 1 tar zxvf /tmp/tmux.tar.gz -C /tmp/tmux --strip 1
pushd /tmp/tmux cd /tmp/tmux
[ -f autogen.sh ] && sh autogen.sh [ -f autogen.sh ] && sh autogen.sh
./configure && make ./configure && make
sudo make install sudo make install
popd cd -
rm -rf /tmp/tmux* rm -rf /tmp/tmux*
fi fi
;; ;;
@ -32,6 +33,6 @@ case "$PM" in
esac esac
# symlink configuration # symlink configuration
lnsf $DIR/tmux.conf ~/.tmux.conf lnsf "$DIR/tmux.conf" ~/.tmux.conf
lnsf $DIR/config/tmux2.8.conf $XDG_CONFIG_HOME/tmux/tmux2.8.conf lnsf "$DIR/config/tmux2.8.conf" "$XDG_CONFIG_HOME/tmux/tmux2.8.conf"
lnsf $DIR/config/tmux2.9.conf $XDG_CONFIG_HOME/tmux/tmux2.9.conf lnsf "$DIR/config/tmux2.9.conf" "$XDG_CONFIG_HOME/tmux/tmux2.9.conf"