Compare commits

...

4 Commits

4 changed files with 64 additions and 17 deletions

View File

@ -61,7 +61,7 @@ configure_install_basic() {
configure_install_useful() {
if [ "$(uname)" = "Darwin" ]; then
[ "$1" != "noupdate" ] && brew update
brew install hexyl bat tree
brew install hexyl bat tree p7zip-full
else
[ "$1" != "noupdate" ] && sudo apt-get update
sudo apt-get install hexyl bat tree fd-find fzf tcptraceroute -y
@ -186,7 +186,7 @@ configure_zsh() {
if ! grep -q "conda initialize" ~/.zshrc; then
if [ -d ~/.miniconda3 ]; then
~/.miniconda3/bin/mamba init zsh
elif [ -d ~/.miniforge3 ]; then
elif [ -d ~/.miniforge3 ]; then
~/.miniforge3/bin/mamba init zsh
fi
fi
@ -307,7 +307,8 @@ configure_nginx() {
fi
if confirm_action "要安装 nginx 吗?" "Y"; then
sudo apt-get update
sudo apt-get install nginx=1.20.2-1~$(lsb_release -cs) -y # TODO E: Version '1.20.2-1~noble' for 'nginx' was not found
# TODO E: Version '1.20.2-1~noble' for 'nginx' was not found
sudo apt-get install nginx=1.20.2-1~$(lsb_release -cs) -y
echo "别忘了把 /etc/nginx/sites-enabled 中的配置文件移动到 /etc/nginx/conf.d 中"
fi
}
@ -436,8 +437,8 @@ configure_node_exporter() {
rm $node_exporter_dir -r
# Generate a self-signed certificate
# openssl req -new -newkey rsa:2048 -days 3650 -nodes -x509 -keyout node_exporter.key -out node_exporter.crt
# -subj "/C=CN/ST=Beijing/L=Beijing/O=nano.ac/CN=localhost"
# openssl req -new -newkey rsa:2048 -days 3650 -nodes -x509 -keyout node_exporter.key -out node_exporter.crt
# -subj "/C=CN/ST=Beijing/L=Beijing/O=nano.ac/CN=localhost"
# -addext "subjectAltName=DNS:localhost,DNS:host.docker.internal,DNS:*.nano.ac,DNS:*.c-4.cc"
if [ ! -d "/etc/node_exporter" ]; then

View File

@ -37,6 +37,41 @@ configure_git() {
fi
}
configure_gpg() {
[ -d ~/.gnupg ] && [ -f ~/.gnupg/gpg.conf ] && return
if confirm_action "要配置 gpg 吗?" "Y"; then
mkdir -p ~/.gnupg
chmod 700 ~/.gnupg
cp $scriptdir/files/gpg.conf ~/.gnupg/gpg.conf
fi
}
configure_git_gpg() {
[ ! -f ~/.gitconfig ] && return
! command_exists git && return
[ -n "$(git config --global user.signingkey)" ] && return
if confirm_action "要配置 git 使用 gpg 签名吗?" "N"; then
if ! command_exists 7za; then
echo "7zip 未安装,请运行 sudo apt install p7zip-full 安装"
return
fi
read_password
cp $scriptdir/files/git.key.zip $tempdir/git.key.zip
7za x -p$password $tempdir/git.key.zip -o$tempdir > /dev/null 2>&1
rm $tempdir/git.key.zip
if [ ! -s $tempdir/git.key ]; then
echo "Wrong password!"
return
fi
gpg --import $tempdir/git.key
rm $tempdir/git.key
git config --global user.signingkey 4ACB54FB3EFF978038BFB374A523E440E24B89CF
git config --global commit.gpgSign true
fi
}
configure_miniconda() {
[ -d ~/.miniconda3 ] && return
[ $offline -eq 1 ] && return
@ -85,16 +120,6 @@ configure_nvm() {
fi
}
configure_gpg() {
[ -d ~/.gnupg ] && [ -f ~/.gnupg/gpg.conf ] && return
if confirm_action "要配置 gpg 吗?" "Y"; then
mkdir -p ~/.gnupg
chmod 700 ~/.gnupg
cp $scriptdir/files/gpg.conf ~/.gnupg/gpg.conf
fi
}
# ============================================================
if [ $# -ne 0 ]; then
@ -102,6 +127,7 @@ if [ $# -ne 0 ]; then
declare -F configure_$func >/dev/null || continue
echo "Configuring $func..."
eval "configure_$func"
unset -f configure_$func
done
return
fi
@ -109,7 +135,8 @@ fi
configure_ssh
configure_ssh_keygen
configure_git
configure_gpg
configure_git_gpg
configure_miniconda
configure_miniforge
configure_nvm
configure_gpg

BIN
files/git.key.zip Normal file

Binary file not shown.

View File

@ -56,7 +56,7 @@ confirm_action() {
}
command_exists() {
command -v "$@" >/dev/null 2>&1;
command -v "$@" >/dev/null 2>&1
}
pkg_install() {
@ -69,6 +69,25 @@ pkg_install() {
fi
}
read_password() {
echo -n "Password: "
password=""
while IFS= read -r -s -n1 char; do
if [[ $char == $'\0' ]]; then
break
elif [[ $char == $'\177' ]]; then
if [ -n "$password" ]; then
password=${password%?}
echo -ne "\b \b"
fi
else
password+="$char"
echo -n "*"
fi
done
echo
}
# ============================================================
check_internet_access