Compare commits

..

1 Commits

Author SHA1 Message Date
aeefe2e895
feat: add nginx log rotation configuration 2025-07-28 17:28:21 +08:00
2 changed files with 19 additions and 17 deletions

View File

@ -1,11 +1,5 @@
# lazy # lazy
一句话命令:`sh -c "$(wget -qO- cc.c-4.cc/lazy.sh)"`
Gist: https://gist.github.com/Konano/d3236c9546a362438096eab1d380b4c7
----
root 用户请使用 [init_root.sh](./init_root.sh) root 用户请使用 [init_root.sh](./init_root.sh)
有 sudo 权限的普通用户请使用 [init_sudo.sh](./init_sudo.sh) 有 sudo 权限的普通用户请使用 [init_sudo.sh](./init_sudo.sh)

View File

@ -61,8 +61,8 @@ configure_install_basic() {
configure_install_useful() { configure_install_useful() {
if [ "$(uname)" = "Darwin" ]; then if [ "$(uname)" = "Darwin" ]; then
[ "$1" != "noupdate" ] && brew update [ "$1" != "noupdate" ] && brew update
brew install hexyl bat tree p7zip brew install hexyl bat tree p7zip-full
brew install mtr brew install hping3 mtr
else else
[ "$1" != "noupdate" ] && sudo apt-get update [ "$1" != "noupdate" ] && sudo apt-get update
sudo apt-get install hexyl bat tree fd-find fzf -y sudo apt-get install hexyl bat tree fd-find fzf -y
@ -182,13 +182,7 @@ configure_zsh() {
# 如果 ~/.zshrc 里面没有 source ~/.zsh_user 则添加 # 如果 ~/.zshrc 里面没有 source ~/.zsh_user 则添加
if ! grep -qx "source ~/.zsh_user" ~/.zshrc; then if ! grep -qx "source ~/.zsh_user" ~/.zshrc; then
if [ "$(uname)" = "Darwin" ]; then sed -i '$a source ~/.zsh_user' ~/.zshrc
# macOS
printf "\nsource ~/.zsh_user\n" >> ~/.zshrc
else
# Linux
sed -i '$a source ~/.zsh_user' ~/.zshrc
fi
fi fi
# 如果 ~/.zshrc 里面没有 conda initialize 则运行 mamba init zsh # 如果 ~/.zshrc 里面没有 conda initialize 则运行 mamba init zsh
@ -339,8 +333,6 @@ configure_fail2ban() {
configure_iptables() { configure_iptables() {
[ $offline -eq 1 ] && return [ $offline -eq 1 ] && return
[ "$(uname)" = "Darwin" ] && return
if command_exists ifquery && systemctl is-active --quiet networking; then if command_exists ifquery && systemctl is-active --quiet networking; then
# ifupdown: /etc/network/if-pre-up.d/iptables-load # ifupdown: /etc/network/if-pre-up.d/iptables-load
[ -f /etc/network/if-pre-up.d/iptables-load ] && return [ -f /etc/network/if-pre-up.d/iptables-load ] && return
@ -470,6 +462,21 @@ configure_node_exporter() {
fi fi
} }
configure_nginx_log() {
[ $offline -eq 1 ] && return
[ "$(uname)" = "Darwin" ] && return
! command_exists nginx && return
[ ! -f /etc/logrotate.d/nginx ] && return
[ -z "$(grep 'daily' /etc/logrotate.d/nginx)" ] && return
if confirm_action "要配置 nginx 日志轮转修改为每周吗?" "N"; then
# 修改 /etc/logrotate.d/nginx 文件,替换 daily 为 weekly
sudo sed -i 's/daily/weekly/' /etc/logrotate.d/nginx
# 重新加载 logrotate 配置
sudo logrotate -f /etc/logrotate.d/nginx
fi
}
# configure_nodejs() { # configure_nodejs() {
# [ -f /usr/local/bin/node ] && return # [ -f /usr/local/bin/node ] && return
# [ $offline -eq 1 ] && return # [ $offline -eq 1 ] && return
@ -570,3 +577,4 @@ configure_bootinfo
configure_oomkiller configure_oomkiller
# configure_swap # configure_swap
configure_node_exporter configure_node_exporter
configure_nginx_log