Skip to content

Commit

Permalink
update template
Browse files Browse the repository at this point in the history
  • Loading branch information
KunSir991 committed Nov 7, 2024
1 parent d4e70b8 commit 5463c40
Showing 1 changed file with 108 additions and 4 deletions.
112 changes: 108 additions & 4 deletions .computenest/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ Artifact:
ImageBuilder:
EcsImage:
RegionId: ap-southeast-1
SourceImageId: centos_7_9_x64_20G_alibase_20240403.vhd
SourceImageId: aliyun_3_x64_20G_alibase_20240819.vhd
SystemDiskSize: 20
InstanceType: ecs.c6.large
InternetMaxBandwidthOut: 5
CommandType: RunShellScript
Expand All @@ -95,7 +96,7 @@ ImageBuilder:
CommandContent: |-
#!/bin/bash
wget https://github.com/cloudreve/Cloudreve/releases/download/3.8.3/cloudreve_3.8.3_linux_amd64.tar.gz
tar -zxvf cloudreve_3.8.3_linux_amd64.tar.gz
tar -zxvf cloudreve_3.8.3_linux_amd64.tar.gz && rm -f cloudreve_3.8.3_linux_amd64.tar.gz
chmod +x ./cloudreve
cat > /etc/systemd/system/cloudreve.service <<EOF
Expand All @@ -115,5 +116,108 @@ ImageBuilder:
systemctl enable cloudreve
systemctl start cloudreve
ARGUS_VERSION=3.5.7 /bin/bash -c "$(curl -sS https://cms-agent-ap-southeast-1.oss-ap-southeast-1-internal.aliyuncs.com/Argus/agent_install_ecs-1.7.sh)" >> /root/install_cms_agent.log 2>&1
# 关闭基础镜像非必要服务,降低基础服务资源占用
systemctl stop systemd-resolved.service
systemctl disable systemd-resolved.service
systemctl stop rpcbind.socket
systemctl stop rpcbind.service
systemctl disable rpcbind.service
systemctl disable rpcbind.socket
function clean_log(){
rm -fv /usr/local/aegis/aegis_update/data/data.[0-9]
rm -fv /usr/local/aegis/aegis_client/aegis_*/data/data.[0-9]
rm -fv /usr/local/aegis/globalcfg/domaincfg.ini
rm -fv /opt/aegis/globalcfg/domaincfg.ini
if [[ -e /usr/local/aegis/globalcfg/domaincfg.ini ]] || [[ -e /opt/aegis/globalcfg/domaincfg.ini ]];then
return 1
fi
rm -f /var/log/anaconda.*
rm -f /var/log/sa/*
rm -rf /var/log/conman*
[ -f /var/log/messages ] && > /var/log/messages
rm -f /var/log/*.[0-9]*
rm -f dmesg*
rm -rfv /var/lib/apt/lists/*
rm -rfv /var/log/installer/syslog
rm -rfv /var/log/journal/*
rm -rfv /var/log/installer/cdebconf/questions.dat
rm -rfv /var/cache/yum/*
rm -rfv /var/cache/dnf/*
rm -rfv /var/lib/yum/history/*
rm -rfv /var/lib/dnf/history*
rm -rfv /var/lib/dhclient/*
rm -rfv /var/lib/dhcp/*
rm -rfv /var/lib/aliyun_init/*
rm -rfv /var/lib/cloud
rm -rfv /etc/ssh/sshd_config.d/50-cloud-init.conf
if [ -d /usr/local/share/aliyun-assist/*/log/ ];then
rm -rfv /usr/local/share/aliyun-assist/*/log/*
fi
rm -rf /usr/local/share/aliyun-assist/plugin
rm -rf /var/log/ecsgo.log*
rm -rf /tmp/*
rm -f /root/{.bash_history,.viminfo,*.cfg,*.log*}
rm -rf /root/script
for i in $(find /var/log/ -type f); do > $i; done
sed -i "/iZ*Z/d" /etc/hosts
sed -i "/AliYun/d" /etc/hosts
# for ubuntu22/24 use cloud-init autoinstall remained hostnaem Aliyun
sed -i "/Aliyun/d" /etc/hosts
sed -i "/debug/d" /etc/hosts
# Clean up useless nameservers to prevent cloudinit local domain name resolution timeout
sed -i "/nameserver/d" $(realpath /etc/resolv.conf)
rm -rfv /tmp/*
[ -d /etc/NetworkManager/system-connections ] && rm -fv /etc/NetworkManager/system-connections/*.nmconnection
if [[ ! -L /etc/udev/rules.d/70-persistent-net.rules ]];then
rm -rfv /etc/udev/rules.d/70-persistent-net.rules
fi
sync
sync
sync
}
function clean_source_cache(){
if [ `which zypper` ]; then
zypper clean; rm -fv /etc/zypp/repos.d/CUSTOM*
elif [ `which apt-get` ]; then
apt-get -q clean; apt-get -q autoclean; apt-get -q -y autoremove;
elif [ `which yum` ]; then
yum clean all;
elif [ `which pkg` ]; then
pkg autoremove
fi
}
function clean_root_passwd(){
passwd -l root
sed -i '/PasswordAuthentication/d' /etc/ssh/sshd_config
echo 'PasswordAuthentication no' >> /etc/ssh/sshd_config
sed -i -e 's/root:[^:]*:/root:*:/g' /etc/shadow
rm -f /root/.ssh/known_hosts
rm -f /etc/ssh/ssh_host_*
}
function clean_cmd_history(){
for user in $(cut -f1 -d: /etc/passwd); do
if [ -f /home/$user/.bash_history ]; then
> /home/$user/.bash_history
fi
done
> /root/.bash_history
}
clean_source_cache
clean_log
clean_root_passwd
clean_cmd_history

0 comments on commit 5463c40

Please sign in to comment.