[bugfix] change && to if then for set -e

This commit is contained in:
Klesh Wong 2020-11-23 10:00:49 +08:00
parent 13993c12d4
commit ed96531512
15 changed files with 97 additions and 49 deletions

View File

@ -8,7 +8,6 @@ log 'Setting up shell'
case "$PM" in case "$PM" in
apt) apt)
! command -v pip3 && "$PDIR/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 silversearcher-ag dash bat -y sudo apt install fish silversearcher-ag dash bat -y
@ -47,7 +46,10 @@ fi
log 'Setting up dash as default shell' log 'Setting up dash as default shell'
sudo /usr/bin/ln -sfT dash /usr/bin/sh sudo /usr/bin/ln -sfT dash /usr/bin/sh
[ "$(awk -F':' '/^'"$USER"'/{print $7}' /etc/passwd)" != "/bin/sh" ] && chsh -s /bin/sh
if [ "$(awk -F':' '/^'"$USER"'/{print $7}' /etc/passwd)" != "/bin/sh" ]; then
chsh -s /bin/sh
fi
log 'Setting up fish' log 'Setting up fish'

View File

@ -6,22 +6,27 @@ DIR=$(dirname "$(readlink -f "$0")")
log 'Setting up mirror list' log 'Setting up mirror list'
! in_china && echo 'Skip mirrors configuration' && return if ! in_china; then
echo 'Skip mirrors configuration'
return
fi
# setup package mirror for CHINA # setup package mirror for CHINA
case "$PM" in case "$PM" in
apt) apt)
# backup original sources.list # backup original sources.list
[ ! -f /etc/apt/sources.list.bak ] && \ if [ ! -f /etc/apt/sources.list.bak ]; then
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
fi
# replace with aliyun mirror # replace with aliyun mirror
awk '$0 ~ /^deb/ {$2="https://mirrors.aliyun.com/ubuntu/"; print}' /etc/apt/sources.list.bak \ awk '$0 ~ /^deb/ {$2="https://mirrors.aliyun.com/ubuntu/"; print}' /etc/apt/sources.list.bak \
| sudo tee /etc/apt/sources.list | sudo tee /etc/apt/sources.list
;; ;;
pacman) pacman)
COUNTRY=China COUNTRY=China
[ ! -f /etc/pacman.d/mirrorlist.bak ] && \ if [ ! -f /etc/pacman.d/mirrorlist.bak ]; then
sudo cp /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.bak sudo cp /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.bak
fi
awk ' awk '
{ {
if (NR < 7) { if (NR < 7) {

View File

@ -4,6 +4,9 @@ set -e
DIR=$(dirname "$(readlink -f "$0")") DIR=$(dirname "$(readlink -f "$0")")
. "$DIR/../env.sh" . "$DIR/../env.sh"
if ! has_cmd python
. "$PDIR/devel/python.sh"
fi
log 'Setting up ranger' log 'Setting up ranger'
# install ranger # install ranger
@ -11,12 +14,10 @@ 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 sudo apt install -y atool p7zip-full unrar
! has_cmd pip3 && "$PDIR/devel/python.sh"
sudo pip3 install ranger-fm ueberzug sudo pip3 install ranger-fm ueberzug
;; ;;
pacman) pacman)
sudo pacman -S --noconfirm --needed atool p7zip unrar sudo pacman -S --noconfirm --needed atool p7zip unrar
! has_cmd pip && "$PDIR/devel/python.sh"
sudo pip install ranger-fm ueberzug sudo pip install ranger-fm ueberzug
;; ;;
esac esac
@ -29,5 +30,6 @@ lnsf "$DIR/ranger/colorschemes/solarizedmod.py" "$XDG_CONFIG_HOME/ranger/colorsc
# install devicons # install devicons
DEVICONS_DIR=$HOME/.config/ranger/plugins/ranger_devicons DEVICONS_DIR=$HOME/.config/ranger/plugins/ranger_devicons
[ ! -d "$DEVICONS_DIR" ] && \ if [ ! -d "$DEVICONS_DIR" ]; then
git clone https://gitee.com/klesh/ranger_devicons.git "$DEVICONS_DIR" git_clone https://gitee.com/klesh/ranger_devicons.git "$DEVICONS_DIR"
fi

View File

@ -15,12 +15,16 @@ case "$PM" in
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 if [ ! -f /tmp/tmux.tar.gz ]; then
curl -L "$TMUX_SRC_URL" -o /tmp/tmux.tar.gz
fi
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
cd /tmp/tmux cd /tmp/tmux
[ -f autogen.sh ] && sh autogen.sh if [ -f autogen.sh ]; then
sh autogen.sh
fi
./configure && make ./configure && make
sudo make install sudo make install
cd - cd -

View File

@ -8,8 +8,12 @@ log 'Setting up vim'
# check dependencies # check dependencies
if [ "$VIM_MODE" = "enhanced" ]; then if [ "$VIM_MODE" = "enhanced" ]; then
! has_cmd npm && "$PDIR/devel/nodejs.sh" if ! has_cmd node; then
! has_cmd pip && "$PDIR/devel/python.sh" . "$PDIR/devel/nodejs.sh"
fi
if ! has_cmd python; then
. "$PDIR/devel/python.sh"
fi
fi fi
# install nvim # install nvim
@ -18,11 +22,15 @@ case "$PM" in
sudo add-apt-repository ppa:neovim-ppa/stable -y sudo add-apt-repository ppa:neovim-ppa/stable -y
sudo apt update sudo apt update
sudo apt install -y neovim sudo apt install -y neovim
[ "$VIM_MODE" = "enhanced" ] && sudo pip3 install pyvim neovim if [ "$VIM_MODE" = "enhanced" ]; then
sudo pip3 install pyvim neovim
fi
;; ;;
pacman) pacman)
sudo pacman -S --noconfirm --needed neovim sudo pacman -S --noconfirm --needed neovim
[ "$VIM_MODE" = "enhanced" ] && sudo pip install pyvim neovim if [ "$VIM_MODE" = "enhanced" ]; then
sudo pip install pyvim neovim
fi
;; ;;
esac esac

View File

@ -1,5 +1,5 @@
{ {
"npm.binPath": "yarnpkg", "npm.binPath": "cnpm",
"python.linting.enable": true, "python.linting.enable": true,
"python.linting.flake8Enabled": true, "python.linting.flake8Enabled": true,
"python.linting.pylintEnabled": false, "python.linting.pylintEnabled": false,

View File

@ -10,7 +10,9 @@ 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 sudo apt install -y docker.io
! has_cmd pip && . "$PDIR/python/install.sh" if ! has_cmd python; then
. "$PDIR/python/install.sh"
fi
sudo pip3 install docker-compose sudo pip3 install docker-compose
;; ;;
pacman) pacman)
@ -29,12 +31,15 @@ if in_china; then
sudo mkdir -p /etc/docker sudo mkdir -p /etc/docker
if [ -f /etc/docker/daemon.json ]; then if [ -f /etc/docker/daemon.json ]; then
# backup # backup
[ ! -f /etc/docker/daemon.bak.json ] && \ if [ ! -f /etc/docker/daemon.bak.json ]; then
sudo cp /etc/docker/daemon.json /etc/docker/daemon.bak.json sudo cp /etc/docker/daemon.json /etc/docker/daemon.bak.json
fi
# read # read
dj=$(cat /etc/docker/daemon.json) dj=$(cat /etc/docker/daemon.json)
fi fi
[ -z "$dj" ] && dj='{}' if [ -z "$dj" ]; then
dj='{}'
fi
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

@ -15,9 +15,10 @@ case "$PM" in
esac esac
# completion for fish # completion for fish
if command -v fish 2>/dev/null ; then if has_cmd fish 2>/dev/null ; then
[ ! -f "$HOME/.config/fish/completions/docker.fish" ] && \ if [ ! -f "$HOME/.config/fish/completions/docker.fish" ]; then
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'
fi
fish -c "fisher add evanlucas/fish-kubectl-completions" fish -c "fisher add evanlucas/fish-kubectl-completions"
fi fi

View File

@ -8,7 +8,9 @@ FILES_PATH=$PREFIX/nodejs
NODE_BIN=$PREFIX/bin/node NODE_BIN=$PREFIX/bin/node
NODE_URL=https://nodejs.org/dist NODE_URL=https://nodejs.org/dist
NODE_VERSION=v14.15.1 NODE_VERSION=v14.15.1
in_china && NODE_URL=https://npm.taobao.org/mirrors/node if in_china; then
NODE_URL=https://npm.taobao.org/mirrors/node
fi
log "Setting up nodejs" log "Setting up nodejs"
@ -18,14 +20,17 @@ lspkgs() {
} }
uninstall() { uninstall() {
[ -f "$FILES_PATH" ] \ if [ -f "$FILES_PATH" ]; then
&& tac "$FILES_PATH" | grep -v '/$' | xargs sudo rm -f tac "$FILES_PATH" | grep -v '/$' | xargs sudo rm -f
fi
} }
install() { install() {
VERSION=$1 VERSION=$1
ARCH=x86 ARCH=x86
[ -x "$NODE_BIN" ] && [ "$("$NODE_BIN" --version)" = "$VERSION" ] && exit 0 if [ -x "$NODE_BIN" ] && [ "$("$NODE_BIN" --version)" = "$VERSION" ]; then
exit 0
fi
case "$(uname -m)" in case "$(uname -m)" in
x86_64) x86_64)
ARCH=x64 ARCH=x64
@ -52,7 +57,9 @@ install() {
| sudo tee "$FILES_PATH" >/dev/null | sudo tee "$FILES_PATH" >/dev/null
# remove download path # remove download path
rm "/tmp/$NAME" rm "/tmp/$NAME"
in_china && sudo npm install -g cnpm --registry=https://registry.npm.taobao.org if in_china; then
sudo npm install -g cnpm --registry=https://registry.npm.taobao.org
fi
} }

View File

@ -24,7 +24,7 @@ case "$PM" in
#sudo apt-get install python3.8 #sudo apt-get install python3.8
#sudo apt install python3.8-distutils #sudo apt install python3.8-distutils
#sudo python3.8 -m pip install --upgrade pip setuptools wheel #sudo python3.8 -m pip install --upgrade pip setuptools wheel
sudo apt install python3 python3-pip python-is-python3 sudo apt install -y python3 python3-pip python-is-python3
;; ;;
pacman) pacman)
sudo pacman -S --noconfirm --needed python python-pip sudo pacman -S --noconfirm --needed python python-pip

View File

@ -9,7 +9,7 @@ if in_china; then
export RUSTUP_DIST_SERVER=https://mirrors.ustc.edu.cn/rust-static export RUSTUP_DIST_SERVER=https://mirrors.ustc.edu.cn/rust-static
export RUSTUP_UPDATE_ROOT=https://mirrors.ustc.edu.cn/rust-static/rustup export RUSTUP_UPDATE_ROOT=https://mirrors.ustc.edu.cn/rust-static/rustup
if command -v fish >/dev/null; then if has_cmd fish >/dev/null; then
echo " echo "
set -x RUSTUP_DIST_SERVER $RUSTUP_DIST_SERVER set -x RUSTUP_DIST_SERVER $RUSTUP_DIST_SERVER
set -x RUSTUP_UPDATE_ROOT $RUSTUP_UPDATE_ROOT set -x RUSTUP_UPDATE_ROOT $RUSTUP_UPDATE_ROOT
@ -18,7 +18,9 @@ if in_china; then
fi fi
# setup cargo mirrors # setup cargo mirrors
[ ! -f "$HOME/.cargo/config" ] && mkdir -p "$HOME/.cargo" && echo " if [ ! -f "$HOME/.cargo/config" ]; then
mkdir -p "$HOME/.cargo"
echo "
[source.crates-io] [source.crates-io]
replace-with = 'ustc' replace-with = 'ustc'
@ -26,10 +28,14 @@ if in_china; then
registry = \"git://mirrors.ustc.edu.cn/crates.io-index\" registry = \"git://mirrors.ustc.edu.cn/crates.io-index\"
" | sed 's/^ *//' > "$HOME/.cargo/config" " | sed 's/^ *//' > "$HOME/.cargo/config"
fi fi
fi
[ ! -f "$HOME/.cargo/bin/rustup" ] \ if [ ! -f "$HOME/.cargo/bin/rustup" ]; then
&& curl -sSf https://cdn.jsdelivr.net/gh/rust-lang-nursery/rustup.rs/rustup-init.sh | sh curl -sSf https://cdn.jsdelivr.net/gh/rust-lang-nursery/rustup.rs/rustup-init.sh | sh
fi
command -v fish >/dev/null && echo " if has_cmd fish; then
echo "
source $HOME/.cargo/env source $HOME/.cargo/env
" | sed 's/^ *//' > "$XDG_CONFIG_HOME/fish/conf.d/cargo.fish" " | sed 's/^ *//' > "$XDG_CONFIG_HOME/fish/conf.d/cargo.fish"
fi

10
env.sh
View File

@ -50,8 +50,11 @@ eqv() {
git_clone() { git_clone() {
mkdir -p "$(dirname "$2")" mkdir -p "$(dirname "$2")"
[ -d "$2" ] && return [ -d "$2" ] && return
echo "$1" | grep -qF 'github.com' && HTTPS_PROXY=$GITHUB_PROXY git clone --depth 1 "$1" "$2" if echo "$1" | grep -qF 'github.com'; then
HTTPS_PROXY=$GITHUB_PROXY git clone --depth 1 "$1" "$2"
else
git clone --depth 1 "$1" "$2" git clone --depth 1 "$1" "$2"
fi
} }
intorepo() { intorepo() {
@ -110,10 +113,9 @@ case "$PM" in
man sudo man sudo
# install yay # install yay
if ! command -v yay >/dev/null; then if ! command -v yay >/dev/null; then
git clone --depth 1 https://aur.archlinux.org/yay.git /tmp/yay intorepo https://aur.archlinux.org/yay.git /tmp/yay
cd /tmp/yay
makepkg -si makepkg -si
cd - exitrepo
fi fi
;; ;;
esac esac

View File

@ -29,11 +29,14 @@ 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
[ ! -f "/tmp/$DEB_PKG_NAME" ] && \ if [ ! -f "/tmp/$DEB_PKG_NAME" ]; then
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
fi
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 --noconfirm --needed ttf-symbola-free if ! fc-list | grep -qi symbola; then
yay -S --noconfirm --needed ttf-symbola-free
fi
;; ;;
esac esac

View File

@ -4,13 +4,16 @@ set -e
DIR=$(dirname "$(readlink -f "$0")") DIR=$(dirname "$(readlink -f "$0")")
. "$DIR/../env.sh" . "$DIR/../env.sh"
if ! has_cmd python; then
. "$PDIR/python/install.sh"
fi
log 'Setting up picom' log 'Setting up picom'
# install dpes # install dpes
case "$PM" in case "$PM" in
apt) apt)
# install build tools # install build tools
! has_cmd pip3 && . "$PDIR/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

View File

@ -11,11 +11,11 @@ case "$PM" in
sudo apt install -y \ sudo apt install -y \
lxappearance arc-theme qt5ct qt5-style-plugins lxappearance arc-theme qt5ct qt5-style-plugins
# install arc-icon-theme # install arc-icon-theme
git clone https://github.com/horst3180/arc-icon-theme --depth 1 /tmp/arc-icon-theme && cd /tmp/arc-icon-theme intorepo https://github.com/horst3180/arc-icon-theme /tmp/arc-icon-theme
./autogen.sh --prefix=/usr ./autogen.sh --prefix=/usr
sudo make install sudo make install
rm -rf /tmp/arc-icon-theme rm -rf /tmp/arc-icon-theme
cd - exitrepo
;; ;;
pacman) pacman)
sudo pacman -S --noconfirm --needed \ sudo pacman -S --noconfirm --needed \