diff --git a/alipay b/alipay new file mode 100644 index 0000000..191f47f --- /dev/null +++ b/alipay @@ -0,0 +1,37 @@ +  +  +  +  +              +                    +                    +                      +                    +                      +                    +            +                +                      +                  +            +                +            +                    +                +                +                    +                  +              +              +              +                  +            +                  +                  +                    +                  +                +  +  +  +  diff --git a/api b/api new file mode 100644 index 0000000..546f623 --- /dev/null +++ b/api @@ -0,0 +1,79 @@ +#!/usr/bin/env bash +clear +# ====== CONFIG (edit here once) ====== +DOMAIN="domain.com" +API_KEY="YOUR_API_KEY" +SECRET_API_KEY="YOUR_SECRET_API_KEY" +TTL="600" +TYPE="A" + +API_BASE="https://api.porkbun.com/api/json/v3/dns" + +echo "====== Porkbun DNS Manager ======" +echo "Domain: $DOMAIN" +echo "" + +echo "Choose an action:" +echo "1) Update subdomain IP" +echo "2) Create new subdomain" +echo "" + +read -p "Enter choice (1 or 2): " ACTION + +case $ACTION in + +# Update existing record +1) + read -p "Enter subdomain to update: " SUBDOMAIN + read -p "Enter new IP address: " IP + + echo "" + echo "Updating ${SUBDOMAIN}.${DOMAIN} -> ${IP}" + read -p "Proceed? (y/n): " CONFIRM + [[ "$CONFIRM" != "y" ]] && echo "Cancelled." && exit 1 + + RESPONSE=$(curl -s -X POST \ + "$API_BASE/editByNameType/${DOMAIN}/${TYPE}/${SUBDOMAIN}" \ + -H "Content-Type: application/json" \ + -d "{ + \"secretapikey\": \"${SECRET_API_KEY}\", + \"apikey\": \"${API_KEY}\", + \"content\": \"${IP}\", + \"ttl\": \"${TTL}\" + }") + + echo "" + echo "API Response:" + echo "$RESPONSE" + ;; + +# Create new subdomain +2) + read -p "Enter new subdomain name: " SUBDOMAIN + read -p "Enter IP address: " IP + + echo "" + echo "Creating ${SUBDOMAIN}.${DOMAIN} -> ${IP}" + + RESPONSE=$(curl -s -X POST \ + "$API_BASE/create/${DOMAIN}" \ + -H "Content-Type: application/json" \ + -d "{ + \"secretapikey\": \"${SECRET_API_KEY}\", + \"apikey\": \"${API_KEY}\", + \"name\": \"${SUBDOMAIN}\", + \"type\": \"${TYPE}\", + \"content\": \"${IP}\", + \"ttl\": \"${TTL}\" + }") + + echo "" + echo "API Response:" + echo "$RESPONSE" + ;; + +*) + echo "Invalid choice." + exit 1 + ;; +esac diff --git a/arch/arch_config.sh b/arch/arch_config.sh new file mode 100644 index 0000000..d529a91 --- /dev/null +++ b/arch/arch_config.sh @@ -0,0 +1,154 @@ +#/bin/bash +clear +#************************************************************************************Print old information +if [[ -f "/root/info" ]]; then + name1=$(awk 'NR==1 {print $1}' /root/info) + disk1=$(awk 'NR==2 {print $1}' /root/info) + boot1=$(awk 'NR==3 {print $1}' /root/info) + encrypt1=$(awk 'NR==4 {print $1}' /root/info) + euuid=$(sed -n '5p' /root/info) + efistub=$(awk 'NR==6 {print $1}' /root/info) + minisys=$(awk 'NR==7 {print $1}' /root/info) + root1=$(sed -n '8p' /root/info) + + echo '--------------System Information--------------' + if [[ -d "/sys/firmware/efi" ]]; then + echo 'UEFI = ON' + else + echo 'UEFI = OFF' + fi + if [[ $efistub = 1 ]]; then + echo 'EFIstub = ON' + else + echo 'EFIstub = OFF' + fi + if [[ $minisys = 1 ]]; then + echo 'Minisys = ON' + else + echo 'Minisys = OFF' + fi + if [[ $encrypt1 = 1 ]]; then + echo 'Encrypt = ON' + echo "Enc UUID = $(sed -n '5p' /root/info)" + else + echo 'Encrypt = OFF' + fi + echo -e "HOOKs = \e[33m$(sed -n '55p' /etc/mkinitcpio.conf | awk -F= '{print $2}')\e[0m" + echo -e "SSH file = \e[33m$(sed -n '33p' /etc/ssh/sshd_config)\e[0m" + echo -e "Localtime = \e[33m$(date +%H:%M\ \ \ %Y/%m/%d)\e[0m" + echo -e "Sudoers = \e[33m$(sed -n '125p' /etc/sudoers)\e[0m" + echo -e "Shell = \e[33m$(echo $SHELL)\e[0m" + if [[ -f "/etc/default/grub" ]]; then + echo -e "GRUB time = \e[33m$(sed -n '4p' /etc/default/grub)\e[0m" + echo -e "GRUB UUID = \e[33m$(sed -n '7p' /etc/default/grub)\e[0m" + fi + if [[ -f "/etc/vconsole.conf" ]]; then + echo -e "Font size = \e[33m$(cat /etc/vconsole.conf)\e[0m" + fi + echo '----------------------------------------------' +else + echo 'No info file' + exit 1 +fi +read -p 'Continue: (YES/NO) ' ask_continue +if [[ $ask_continue != YES ]]; then + echo -e "\e[31mAborted ...\e[0m" + exit 1 +fi +#************************************************************************************Change information +if [[ -f "/root/info" ]]; then + if [[ $efistub = 1 ]]; then #----------------------------------------------------------EFI Stub + if [[ $encrypt1 = 1 ]]; then #-------------------------------EFI Stub Encrypt + efibootmgr --create --disk $disk1 --part $boot1 --label "Arch Linux LTS" --loader \vmlinuz-linux-lts --unicode "rd.luks.name=${euuid}=system root=/dev/mapper/OS-ROOT rw rd.luks.options=password-echo=no initrd=\initramfs-linux-lts.img" + sed -i '55d' /etc/mkinitcpio.conf + sed -i '55i HOOKS=(base systemd autodetect microcode modconf kms keyboard keymap sd-vconsole block sd-encrypt lvm2 filesystems fsck)' /etc/mkinitcpio.conf + else #-------------------------------------------------------EFI Stub + efibootmgr --create --disk $disk1 --part $boot1 --label "Arch Linux LTS" --loader \vmlinuz-linux-lts --unicode "root=${root1} rw initrd=\initramfs-linux-lts.img" + fi + else #---------------------------------------------------------------------------------GRUB + sed -i '4d' /etc/default/grub + sed -i '4i GRUB_TIMEOUT=0' /etc/default/grub + if [[ $encrypt1 = 1 ]]; then #-------------------------------GEUB Encrypt + sed -i '7d' /etc/default/grub + sed -i "7i GRUB_CMDLINE_LINUX=cryptdevice=UUID=${euuid}:SYSTEM root=/dev/mapper/os-root" /etc/default/grub + sed -i '55d' /etc/mkinitcpio.conf + sed -i '55i HOOKS=(base udev autodetect microcode modconf kms keyboard keymap consolefont block encrypt lvm2 filesystems fsck)' /etc/mkinitcpio.conf + fi + if [ -d "/sys/firmware/efi" ]; then #------------------------UEFI + echo -e "\e[32mUEFI\e[0m" + grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=Unix + echo -e "\e[32mgrub installed\e[0m" + grub-mkconfig -o /boot/grub/grub.cfg + echo -e "\e[32mgrub.cfg installed\e[0m" + else #-------------------------------------------------------BIOS + echo -e "\e[32mBIOS\e[0m" + grub-install --target=i386-pc /dev/vda + echo -e "\e[32mgrub installed\e[0m" + grub-mkconfig -o /boot/grub/grub.cfg + echo -e "\e[32mgrub.cfg installed\e[0m" + fi + fi + if [[ $minisys != 1 ]]; then + systemctl enable docker >/dev/null 2>&1 + systemctl enable fail2ban >/dev/null 2>&1 + systemctl enable nginx >/dev/null 2>&1 + mkdir /etc/nginx/conf.d + sed -i '22a \ \ \ \ include /etc/nginx/conf.d/*.conf;' /etc/nginx/nginx.conf + fi +else + echo 'No info file' +fi + +#------------------------------------------------------------------------------Common Services +#Change SSH +sed -i '33d' /etc/ssh/sshd_config +sed -i '33i PermitRootLogin yes' /etc/ssh/sshd_config +#Change issue +echo Welcome back > /etc/issue +#Change hostname +echo $name1 > /etc/hostname +#Change time +ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime +#Change font +echo 'FONT=ter-v28b' > /etc/vconsole.conf +#Change sudoers file +sed -i '125d' /etc/sudoers +sed -i '125i %wheel ALL=(ALL:ALL) ALL' /etc/sudoers +#enable ssh networkmanager +systemctl enable sshd >/dev/null 2>&1 +systemctl enable NetworkManager >/dev/null 2>&1 +#Add my key +bash <(curl -sL sh.lihanzhang.cn/pub) +chsh -s /bin/zsh +ln -s /bin/vim /bin/vi +#Create my folder +mkdir /file +mkdir /www/log -p +mkdir /frp +#arch environment +#Add user +useradd -m olivia -G wheel +mkdir -p ~/.local/bin +curl https://sh.lihanzhang.cn/arch/profile -so ~/.local/bin/.bashrc +curl https://sh.lihanzhang.cn/arch/zshrc -so ~/.zshrc +curl https://sh.lihanzhang.cn/arch/vimrc -so ~/.vimrc +curl https://sh.lihanzhang.cn/arch/fail2ban.conf -so /etc/fail2ban/jail.conf +mkinitcpio -p linux-lts +#************************************************************************************Print Changed information +echo '--------------System Information--------------' +echo -e "HOOKs = \e[33m$(sed -n '55p' /etc/mkinitcpio.conf | awk -F= '{print $2}')\e[0m" +echo -e "SSH file = \e[33m$(sed -n '33p' /etc/ssh/sshd_config)\e[0m" +echo -e "Issue = \e[33m$(cat /etc/issue)\e[0m" +echo -e "Hostname = \e[33m$(cat /etc/hostname)\e[0m" +echo -e "Localtime = \e[33m$(date +%H:%M\ \ \ %Y/%m/%d)\e[0m" +echo -e "Sudoers = \e[33m$(sed -n '125p' /etc/sudoers)\e[0m" +echo -e "Shell = \e[33m$(echo $SHELL)\e[0m" +echo -e "Font size = \e[33m$(cat /etc/vconsole.conf)\e[0m" +if [[ -f "/etc/default/grub" ]]; then + echo -e "GRUB time = \e[33m$(sed -n '4p' /etc/default/grub)\e[0m" + echo -e "GRUB UUID = \e[33m$(sed -n '7p' /etc/default/grub)\e[0m" +fi +echo '----------------------------------------------' +rm -rf /root/info +rm -rf /arch_config.sh +echo -e "\e[32m------Please change password------\e[0m" diff --git a/arch/fail2ban.conf b/arch/fail2ban.conf new file mode 100644 index 0000000..6f1e79b --- /dev/null +++ b/arch/fail2ban.conf @@ -0,0 +1,10 @@ +[sshd] +enabled = true +port = ssh +filter = sshd +backend = systemd +logpath = journal +maxretry = 3 +bantime = 1d +findtime = 10m +action = iptables[name=SSH, port=ssh, protocol=tcp] diff --git a/arch/profile b/arch/profile new file mode 100644 index 0000000..b46b08e --- /dev/null +++ b/arch/profile @@ -0,0 +1,56 @@ +#!/bin/bash +code() { + if [ $# -eq 0 ]; then + echo "Usage: code [-d]