add configure_hostname
This commit is contained in:
parent
cd3261d399
commit
3d0dd170ba
@ -82,6 +82,8 @@ local exit_code="%(?,,C:%{$fg[red]%}%?%{$reset_color%})"
|
||||
|
||||
PROMPT="
|
||||
%{$terminfo[bold]$fg[blue]%}#%{$reset_color%} \
|
||||
%{$fg[green]%}%m \
|
||||
%{$reset_color%}in \
|
||||
%{$terminfo[bold]$fg[yellow]%}%~%{$reset_color%}\
|
||||
${hg_info}\
|
||||
${git_info}\
|
||||
|
||||
28
init_root.sh
28
init_root.sh
@ -38,7 +38,7 @@ check_google_access() {
|
||||
configure_ssh() {
|
||||
[ -f ~/.ssh/authorized_keys ] && return
|
||||
|
||||
read -p "要配置 .ssh 吗?[Y/n]: " response
|
||||
read -p "要配置 .ssh 吗?[Y]: " response
|
||||
|
||||
if [[ -z "$response" ]] || [[ $response =~ ^[Yy]$ ]]; then
|
||||
mkdir -p ~/.ssh
|
||||
@ -49,7 +49,7 @@ configure_ssh() {
|
||||
configure_ssh_keygen() {
|
||||
[ -f ~/.ssh/id_ed25519.pub ] && return
|
||||
|
||||
read -p "要生成 sshkey 吗?[y/N]: " response
|
||||
read -p "要生成 sshkey 吗?[N]: " response
|
||||
|
||||
if [[ $response =~ ^[Yy]$ ]]; then
|
||||
mkdir -p ~/.ssh
|
||||
@ -61,7 +61,7 @@ configure_ssh_keygen() {
|
||||
configure_nano() {
|
||||
[ -f ~/.nanorc ] && return
|
||||
|
||||
read -p "要配置 nano 吗?[Y/n]: " response
|
||||
read -p "要配置 nano 吗?[Y]: " response
|
||||
|
||||
if [[ -z "$response" ]] || [[ $response =~ ^[Yy]$ ]]; then
|
||||
apt install nano -y
|
||||
@ -72,7 +72,7 @@ configure_nano() {
|
||||
configure_vim() {
|
||||
[ -f ~/.vimrc ] && return
|
||||
|
||||
read -p "要配置 vim 吗?[Y/n]: " response
|
||||
read -p "要配置 vim 吗?[Y]: " response
|
||||
|
||||
if [[ -z "$response" ]] || [[ $response =~ ^[Yy]$ ]]; then
|
||||
apt install vim -y
|
||||
@ -81,7 +81,7 @@ configure_vim() {
|
||||
}
|
||||
|
||||
configure_apt_upgrade() {
|
||||
read -p "要运行 apt upgrade 吗?[y/N]: " response
|
||||
read -p "要运行 apt upgrade 吗?[N]: " response
|
||||
|
||||
if [[ $response =~ ^[Yy]$ ]]; then
|
||||
apt update
|
||||
@ -91,7 +91,7 @@ configure_apt_upgrade() {
|
||||
}
|
||||
|
||||
configure_apt_install() {
|
||||
read -p "要运行 apt install 吗?[Y/n]: " response
|
||||
read -p "要运行 apt install 吗?[Y]: " response
|
||||
|
||||
if [[ -z "$response" ]] || [[ $response =~ ^[Yy]$ ]]; then
|
||||
apt update
|
||||
@ -112,7 +112,7 @@ configure_apt_install() {
|
||||
configure_zsh() {
|
||||
[ -f ~/.zshrc ] && return
|
||||
|
||||
read -p "要配置 zsh 吗?[Y/n]: " response
|
||||
read -p "要配置 zsh 吗?[Y]: " response
|
||||
|
||||
if [[ -z "$response" ]] || [[ $response =~ ^[Yy]$ ]]; then
|
||||
apt install zsh -y
|
||||
@ -132,7 +132,7 @@ configure_zsh() {
|
||||
configure_tmux() {
|
||||
[ -f ~/.tmux.conf ] && return
|
||||
|
||||
read -p "要配置 tmux 吗?[Y/n]: " response
|
||||
read -p "要配置 tmux 吗?[Y]: " response
|
||||
|
||||
if [[ -z "$response" ]] || [[ $response =~ ^[Yy]$ ]]; then
|
||||
apt install tmux -y
|
||||
@ -149,7 +149,7 @@ configure_tmux() {
|
||||
configure_iptables() {
|
||||
[ -f /etc/network/if-pre-up.d/iptables-load ] && return
|
||||
|
||||
read -p "要配置 iptables 吗?[n/Y]: " response
|
||||
read -p "要配置 iptables 吗?[N]: " response
|
||||
|
||||
if [[ $response =~ ^[Yy]$ ]]; then
|
||||
cp $scriptdir/files/iptables-load /etc/network/if-pre-up.d/iptables-load
|
||||
@ -158,6 +158,15 @@ configure_iptables() {
|
||||
fi
|
||||
}
|
||||
|
||||
configure_hostname() {
|
||||
read -p "要修改 hostname 吗?[N]: " response
|
||||
|
||||
if [[ $response =~ ^[Yy]$ ]]; then
|
||||
read -p "hostname: " new_hostname
|
||||
echo $new_hostname | tee /etc/hostname > /dev/null
|
||||
fi
|
||||
}
|
||||
|
||||
if [[ $EUID -ne 0 ]]; then
|
||||
echo "This script must be run as root."
|
||||
exit 1
|
||||
@ -173,3 +182,4 @@ configure_apt_install
|
||||
configure_zsh
|
||||
configure_tmux
|
||||
configure_iptables
|
||||
configure_hostname
|
||||
|
||||
26
init_sudo.sh
26
init_sudo.sh
@ -38,7 +38,7 @@ check_google_access() {
|
||||
configure_ssh() {
|
||||
[ -f ~/.ssh/authorized_keys ] && return
|
||||
|
||||
read -p "要配置 .ssh 吗?[Y/n]: " response
|
||||
read -p "要配置 .ssh 吗?[Y]: " response
|
||||
|
||||
if [[ -z "$response" ]] || [[ $response =~ ^[Yy]$ ]]; then
|
||||
mkdir -p ~/.ssh
|
||||
@ -49,7 +49,7 @@ configure_ssh() {
|
||||
configure_ssh_keygen() {
|
||||
[ -f ~/.ssh/id_ed25519.pub ] && return
|
||||
|
||||
read -p "要生成 sshkey 吗?[y/N]: " response
|
||||
read -p "要生成 sshkey 吗?[N]: " response
|
||||
|
||||
if [[ $response =~ ^[Yy]$ ]]; then
|
||||
mkdir -p ~/.ssh
|
||||
@ -61,7 +61,7 @@ configure_ssh_keygen() {
|
||||
configure_nano() {
|
||||
[ -f ~/.nanorc ] && return
|
||||
|
||||
read -p "要配置 nano 吗?[Y/n]: " response
|
||||
read -p "要配置 nano 吗?[Y]: " response
|
||||
|
||||
if [[ -z "$response" ]] || [[ $response =~ ^[Yy]$ ]]; then
|
||||
sudo apt install nano -y
|
||||
@ -72,7 +72,7 @@ configure_nano() {
|
||||
configure_vim() {
|
||||
[ -f ~/.vimrc ] && return
|
||||
|
||||
read -p "要配置 vim 吗?[Y/n]: " response
|
||||
read -p "要配置 vim 吗?[Y]: " response
|
||||
|
||||
if [[ -z "$response" ]] || [[ $response =~ ^[Yy]$ ]]; then
|
||||
sudo apt install vim -y
|
||||
@ -81,7 +81,7 @@ configure_vim() {
|
||||
}
|
||||
|
||||
configure_apt_upgrade() {
|
||||
read -p "要运行 apt upgrade 吗?[y/N]: " response
|
||||
read -p "要运行 apt upgrade 吗?[N]: " response
|
||||
|
||||
if [[ $response =~ ^[Yy]$ ]]; then
|
||||
sudo apt update
|
||||
@ -91,7 +91,7 @@ configure_apt_upgrade() {
|
||||
}
|
||||
|
||||
configure_apt_install() {
|
||||
read -p "要运行 apt install 吗?[Y/n]: " response
|
||||
read -p "要运行 apt install 吗?[Y]: " response
|
||||
|
||||
if [[ -z "$response" ]] || [[ $response =~ ^[Yy]$ ]]; then
|
||||
sudo apt update
|
||||
@ -112,7 +112,7 @@ configure_apt_install() {
|
||||
configure_zsh() {
|
||||
[ -f ~/.zshrc ] && return
|
||||
|
||||
read -p "要配置 zsh 吗?[Y/n]: " response
|
||||
read -p "要配置 zsh 吗?[Y]: " response
|
||||
|
||||
if [[ -z "$response" ]] || [[ $response =~ ^[Yy]$ ]]; then
|
||||
sudo apt install zsh -y
|
||||
@ -132,7 +132,7 @@ configure_zsh() {
|
||||
configure_tmux() {
|
||||
[ -f ~/.tmux.conf ] && return
|
||||
|
||||
read -p "要配置 tmux 吗?[Y/n]: " response
|
||||
read -p "要配置 tmux 吗?[Y]: " response
|
||||
|
||||
if [[ -z "$response" ]] || [[ $response =~ ^[Yy]$ ]]; then
|
||||
sudo apt install tmux -y
|
||||
@ -158,6 +158,15 @@ configure_iptables() {
|
||||
fi
|
||||
}
|
||||
|
||||
configure_hostname() {
|
||||
read -p "要修改 hostname 吗?[N]: " response
|
||||
|
||||
if [[ $response =~ ^[Yy]$ ]]; then
|
||||
read -p "hostname: " new_hostname
|
||||
echo $new_hostname | sudo tee /etc/hostname > /dev/null
|
||||
fi
|
||||
}
|
||||
|
||||
if [[ $EUID -eq 0 ]]; then
|
||||
echo "This script should not be run as root."
|
||||
exit 1
|
||||
@ -173,3 +182,4 @@ configure_apt_install
|
||||
configure_zsh
|
||||
configure_tmux
|
||||
configure_iptables
|
||||
configure_hostname
|
||||
|
||||
Loading…
Reference in New Issue
Block a user