.gitconfig; tools/alpine.sh; mkdir -p when install; restruct ubuntu.sh

This commit is contained in:
Dict Xiong 2022-05-21 14:47:39 +08:00
parent d5bf057e65
commit 1901c3a9ce
4 changed files with 57 additions and 13 deletions

3
.gitconfig2 Normal file
View File

@ -0,0 +1,3 @@
[user]
email = me@beardic.cn
name = Dict Xiong

View File

@ -115,6 +115,7 @@ insert_if_not_exist()
filename=$1 filename=$1
line=$2 line=$2
fmt_note "installing \"$line\" into \"$filename\" ..." fmt_note "installing \"$line\" into \"$filename\" ..."
mkdir -p $(dirname "$filename")
if [ ! -f "$filename" ]; then if [ ! -f "$filename" ]; then
touch $filename touch $filename
fi fi
@ -140,6 +141,7 @@ create_symlink()
fmt_error "\"$src\" does not exist! aborting this job ..." fmt_error "\"$src\" does not exist! aborting this job ..."
return 1 return 1
fi fi
mkdir -p $(driname "$dest")
if [ -f "$dest" ]; then if [ -f "$dest" ]; then
if [ "$(readlink $dest)" -ef "$src" ]; then if [ "$(readlink $dest)" -ef "$src" ]; then
return 0 return 0
@ -212,6 +214,7 @@ install(){
insert_if_not_exist "${HOME}/.zshrc" "source ${dotfile_home_path}/.zshrc2" insert_if_not_exist "${HOME}/.zshrc" "source ${dotfile_home_path}/.zshrc2"
insert_if_not_exist "${HOME}/.tmux.conf" "source-file ${dotfile_home_path}/.tmux.conf2" insert_if_not_exist "${HOME}/.tmux.conf" "source-file ${dotfile_home_path}/.tmux.conf2"
insert_if_not_exist "${HOME}/.vimrc" "source ${dotfile_home_path}/.vimrc2" insert_if_not_exist "${HOME}/.vimrc" "source ${dotfile_home_path}/.vimrc2"
insert_if_not_exist "${HOME}/.gitconfig" "[include] path = \"${dotfile_home_path}/.gitconfig2\""
create_symlink "${dotfile_path}/.ssh/authorized_keys2" "${HOME}/.ssh/authorized_keys2" create_symlink "${dotfile_path}/.ssh/authorized_keys2" "${HOME}/.ssh/authorized_keys2"
# those that won't be uninstalled in the future # those that won't be uninstalled in the future
install_tmux_tpm install_tmux_tpm
@ -226,6 +229,7 @@ uninstall(){
delete_if_exist "${HOME}/.zshrc" "source ${dotfile_home_path}/.zshrc2" delete_if_exist "${HOME}/.zshrc" "source ${dotfile_home_path}/.zshrc2"
delete_if_exist "${HOME}/.tmux.conf" "source-file ${dotfile_home_path}/.tmux.conf2" delete_if_exist "${HOME}/.tmux.conf" "source-file ${dotfile_home_path}/.tmux.conf2"
delete_if_exist "${HOME}/.vimrc" "source ${dotfile_home_path}/.vimrc2" delete_if_exist "${HOME}/.vimrc" "source ${dotfile_home_path}/.vimrc2"
delete_if_exist "${HOME}/.gitconfig" "[include] path = \"${dotfile_home_path}/.gitconfig2\""
delete_link_if_match "${dotfile_path}/.ssh/authorized_keys2" "${HOME}/.ssh/authorized_keys2" delete_link_if_match "${dotfile_path}/.ssh/authorized_keys2" "${HOME}/.ssh/authorized_keys2"
fmt_note "done uninstalling!" fmt_note "done uninstalling!"
fi fi

38
tools/alpine.sh Executable file
View File

@ -0,0 +1,38 @@
#!/bin/bash
if [[ $USER != "root" ]]; then
echo "must run as root!"
exit 1
fi
set_mirror()
{
#MIRROR=${1:="mirrors.tuna.tsinghua.edu.cn"}
#MIRROR=${MIRROR//\//\\\/}
#sed -i 's/(archive|security).ubuntu.com/${MIRROR}/g' /etc/apt/sources.list
echo "to-do ..."
}
apk_add()
{
apk update
# mass installation
apk add zsh git tmux vim curl wget bash python3 htop gcc g++ cmake make fzf perl linux-headers bind-tools iputils man-db
#for i in {fzf,ripgrep}; do apk add $i -y; done
# who am i
git config --global user.email "me@beardic.cn"
git config --global user.name "Dict Xiong"
}
router()
{
case $1 in
apk-add ) apk_add ;;
#set-mirror ) set_mirror $2 ;;
* ) echo unknown command "$1". available: apk-add;;
esac
}
router $@

View File

@ -5,26 +5,24 @@ if [[ $USER != "root" ]]; then
exit 1 exit 1
fi fi
init() set_mirror()
{
MIRROR=${1:="mirrors.tuna.tsinghua.edu.cn"}
MIRROR=${MIRROR//\//\\\/}
sed -i 's/(archive|security).ubuntu.com/${MIRROR}/g' /etc/apt/sources.list
}
apt_install()
{ {
# basic packages # basic packages
apt update apt update
for i in {man-db,vim,ca-certificates}; do apt install $i -y; done for i in {man-db,vim,ca-certificates}; do apt install $i -y; done
# apt source
${MIRROR:="mirrors.tuna.tsinghua.edu.cn"}
MIRROR=${MIRROR//\//\\\/}
sed -i 's/(archive|security).ubuntu.com/${MIRROR}/g' /etc/apt/sources.list
# mass installation # mass installation
apt update apt update
apt install git tmux zsh curl wget dialog net-tools dnsutils netcat traceroute sudo python3 python3-pip cron inetutils-ping openssh-client openssh-server htop gcc g++ cmake apt install git tmux zsh curl wget dialog net-tools dnsutils netcat traceroute sudo python3 python3-pip cron inetutils-ping openssh-client openssh-server htop gcc g++ cmake make
for i in {fzf,ripgrep}; do apt install $i -y; done for i in {fzf,ripgrep}; do apt install $i -y; done
# custom dotfiles (usually not needed)
mkdir -p ~/.ssh
# cd ~ && git clone https://gitee.com/dictxiong/dotfiles && ./dotfiles/install.sh
# who am i # who am i
git config --global user.email "me@beardic.cn" git config --global user.email "me@beardic.cn"
git config --global user.name "Dict Xiong" git config --global user.name "Dict Xiong"
@ -33,8 +31,9 @@ init()
router() router()
{ {
case $1 in case $1 in
init ) init ;; apt-install ) apt_install ;;
* ) echo unknown command "$1". available: init ;; set-mirror ) set_mirror $2 ;;
* ) echo unknown command "$1". available: apt-install, set-mirror;;
esac esac
} }