[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
apt)
! command -v pip3 && "$PDIR/python/install.sh"
sudo add-apt-repository ppa:fish-shell/release-3 -y
sudo apt update
sudo apt install fish silversearcher-ag dash bat -y
@ -47,7 +46,10 @@ fi
log 'Setting up dash as default shell'
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'

View File

@ -6,22 +6,27 @@ DIR=$(dirname "$(readlink -f "$0")")
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
case "$PM" in
apt)
# 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
fi
# replace with aliyun mirror
awk '$0 ~ /^deb/ {$2="https://mirrors.aliyun.com/ubuntu/"; print}' /etc/apt/sources.list.bak \
| sudo tee /etc/apt/sources.list
;;
pacman)
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
fi
awk '
{
if (NR < 7) {

View File

@ -4,6 +4,9 @@ set -e
DIR=$(dirname "$(readlink -f "$0")")
. "$DIR/../env.sh"
if ! has_cmd python
. "$PDIR/devel/python.sh"
fi
log 'Setting up ranger'
# install ranger
@ -11,12 +14,10 @@ case "$PM" in
apt)
# atool/p7zip-full for archive previewing/extracting etc
sudo apt install -y atool p7zip-full unrar
! has_cmd pip3 && "$PDIR/devel/python.sh"
sudo pip3 install ranger-fm ueberzug
;;
pacman)
sudo pacman -S --noconfirm --needed atool p7zip unrar
! has_cmd pip && "$PDIR/devel/python.sh"
sudo pip install ranger-fm ueberzug
;;
esac
@ -29,5 +30,6 @@ lnsf "$DIR/ranger/colorschemes/solarizedmod.py" "$XDG_CONFIG_HOME/ranger/colorsc
# install devicons
DEVICONS_DIR=$HOME/.config/ranger/plugins/ranger_devicons
[ ! -d "$DEVICONS_DIR" ] && \
git clone https://gitee.com/klesh/ranger_devicons.git "$DEVICONS_DIR"
if [ ! -d "$DEVICONS_DIR" ]; then
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
TMUX_SRC_URL="https://gitee.com/klesh/tmux/repository/archive/$TMUX_VER?format=tar.gz"
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
mkdir -p /tmp/tmux
tar zxvf /tmp/tmux.tar.gz -C /tmp/tmux --strip 1
cd /tmp/tmux
[ -f autogen.sh ] && sh autogen.sh
if [ -f autogen.sh ]; then
sh autogen.sh
fi
./configure && make
sudo make install
cd -

View File

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

View File

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

View File

@ -10,7 +10,9 @@ case "$PM" in
# snap docker will intefere native docker.io, must be dealt with
sudo snap remove --purge docker
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
;;
pacman)
@ -29,12 +31,15 @@ if in_china; then
sudo mkdir -p /etc/docker
if [ -f /etc/docker/daemon.json ]; then
# 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
fi
# read
dj=$(cat /etc/docker/daemon.json)
fi
[ -z "$dj" ] && dj='{}'
if [ -z "$dj" ]; then
dj='{}'
fi
echo $dj | jq '. + {"registry-mirrors": ["https://izuhlbap.mirror.aliyuncs.com"]}' | \
sudo tee /etc/docker/daemon.json
sudo systemctl restart docker

View File

@ -15,9 +15,10 @@ case "$PM" in
esac
# completion for fish
if command -v fish 2>/dev/null ; then
[ ! -f "$HOME/.config/fish/completions/docker.fish" ] && \
if has_cmd fish 2>/dev/null ; then
if [ ! -f "$HOME/.config/fish/completions/docker.fish" ]; then
curl -Lo "$HOME/.config/fish/completions/docker.fish" --create-dirs \
'https://github.com/docker/cli/raw/master/contrib/completion/fish/docker.fish'
fi
fish -c "fisher add evanlucas/fish-kubectl-completions"
fi

View File

@ -8,7 +8,9 @@ FILES_PATH=$PREFIX/nodejs
NODE_BIN=$PREFIX/bin/node
NODE_URL=https://nodejs.org/dist
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"
@ -18,14 +20,17 @@ lspkgs() {
}
uninstall() {
[ -f "$FILES_PATH" ] \
&& tac "$FILES_PATH" | grep -v '/$' | xargs sudo rm -f
if [ -f "$FILES_PATH" ]; then
tac "$FILES_PATH" | grep -v '/$' | xargs sudo rm -f
fi
}
install() {
VERSION=$1
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
x86_64)
ARCH=x64
@ -52,7 +57,9 @@ install() {
| sudo tee "$FILES_PATH" >/dev/null
# remove download path
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 install python3.8-distutils
#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)
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_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 "
set -x RUSTUP_DIST_SERVER $RUSTUP_DIST_SERVER
set -x RUSTUP_UPDATE_ROOT $RUSTUP_UPDATE_ROOT
@ -18,18 +18,24 @@ if in_china; then
fi
# setup cargo mirrors
[ ! -f "$HOME/.cargo/config" ] && mkdir -p "$HOME/.cargo" && echo "
[source.crates-io]
replace-with = 'ustc'
if [ ! -f "$HOME/.cargo/config" ]; then
mkdir -p "$HOME/.cargo"
echo "
[source.crates-io]
replace-with = 'ustc'
[source.ustc]
registry = \"git://mirrors.ustc.edu.cn/crates.io-index\"
" | sed 's/^ *//' > "$HOME/.cargo/config"
[source.ustc]
registry = \"git://mirrors.ustc.edu.cn/crates.io-index\"
" | sed 's/^ *//' > "$HOME/.cargo/config"
fi
fi
[ ! -f "$HOME/.cargo/bin/rustup" ] \
&& curl -sSf https://cdn.jsdelivr.net/gh/rust-lang-nursery/rustup.rs/rustup-init.sh | sh
if [ ! -f "$HOME/.cargo/bin/rustup" ]; then
curl -sSf https://cdn.jsdelivr.net/gh/rust-lang-nursery/rustup.rs/rustup-init.sh | sh
fi
command -v fish >/dev/null && echo "
source $HOME/.cargo/env
" | sed 's/^ *//' > "$XDG_CONFIG_HOME/fish/conf.d/cargo.fish"
if has_cmd fish; then
echo "
source $HOME/.cargo/env
" | sed 's/^ *//' > "$XDG_CONFIG_HOME/fish/conf.d/cargo.fish"
fi

12
env.sh
View File

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

View File

@ -29,11 +29,14 @@ case "$PM" in
# https://code.google.com/p/chromium/issues/detail?id=233851
# use debian package instead
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
fi
ar p "/tmp/$DEB_PKG_NAME" data.tar.xz | sudo tar Jxv -C /
# 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

View File

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

View File

@ -11,11 +11,11 @@ case "$PM" in
sudo apt install -y \
lxappearance arc-theme qt5ct qt5-style-plugins
# 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
sudo make install
rm -rf /tmp/arc-icon-theme
cd -
exitrepo
;;
pacman)
sudo pacman -S --noconfirm --needed \