Update from Original Repository #97
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Update from Original Repository | |
on: | |
schedule: | |
- cron: '0 0 * * *' # Runs daily at midnight | |
workflow_dispatch: # Allows manual triggering of the workflow | |
jobs: | |
update-files: | |
runs-on: ubuntu-latest | |
steps: | |
# Check out the target repository (your repo) | |
- name: Checkout Target Repository | |
uses: actions/checkout@v3 | |
with: | |
ref: main # Use the main branch for testing | |
# Remove any leftover submodule configurations | |
- name: Cleanup Submodule Configurations | |
run: | | |
git submodule deinit -f --all || true | |
rm -f .gitmodules | |
git config --remove-section submodule || true | |
# Clone the original repository | |
- name: Clone Original Repository | |
run: | | |
mkdir -p tmp-original-repo | |
git clone --depth 1 https://github.com/community-scripts/ProxmoxVE tmp-original-repo | |
rm -rf tmp-original-repo/.git # Remove Git metadata to prevent submodule errors | |
# Copy and modify the necessary files | |
- name: Sync and Modify Files | |
run: | | |
mkdir -p ct install misc | |
cp tmp-original-repo/ct/create_lxc.sh ct/create_lxc.sh | |
cp tmp-original-repo/ct/pihole.sh ct/piblocklxc.sh | |
cp tmp-original-repo/install/pihole-install.sh install/piblocklxc-install.sh | |
cp tmp-original-repo/misc/build.func misc/build.func | |
cp tmp-original-repo/misc/install.func misc/install.func | |
# Replace URLs, Backtitle, Author, Copyright, License, and DESCRIPTION | |
- name: Update Files | |
run: | | |
# Replace URLs | |
sed -i 's|https://github.com/community-scripts/ProxmoxVE|https://github.com/mschabhuettl/PiBlockLXC|g' ct/create_lxc.sh ct/piblocklxc.sh install/piblocklxc-install.sh misc/build.func misc/install.func | |
sed -i 's|https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func|https://raw.githubusercontent.com/mschabhuettl/PiBlockLXC/main/misc/build.func|g' ct/piblocklxc.sh | |
sed -i 's|https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/ct/create_lxc.sh|https://raw.githubusercontent.com/mschabhuettl/PiBlockLXC/main/ct/create_lxc.sh|g' misc/build.func | |
sed -i 's|https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/install/$var_install.sh|https://raw.githubusercontent.com/mschabhuettl/PiBlockLXC/main/install/$var_install.sh|g' misc/build.func | |
# Replace DESCRIPTION Block | |
sed -i '/# Generate LXC Description/,/^ pct set.*-description.*$/c\ # Generate LXC Description\n DESCRIPTION=$(cat <<EOF\n<div align='\''center'\''><a href='\''https://Helper-Scripts.com'\'' target='\''_blank'\'' rel='\''noopener noreferrer'\''><img src='\''https://raw.githubusercontent.com/mschabhuettl/PiBlockLXC/main/misc/images/logo-81x112.png'\''/></a>\n\n # ${APP} LXC\n </div>\nEOF\n)' misc/build.func | |
# Replace Backtitle | |
sed -i 's/--backtitle "Proxmox VE Helper Scripts"/--backtitle "PiBlockLXC"/g' ct/create_lxc.sh ct/piblocklxc.sh install/piblocklxc-install.sh misc/build.func misc/install.func | |
# Add ", mschabhuettl" to Author lines | |
sed -i '/# Author:/ s/$/, mschabhuettl/' ct/create_lxc.sh ct/piblocklxc.sh install/piblocklxc-install.sh misc/build.func misc/install.func | |
# Append ", mschabhuettl" to Copyright lines | |
sed -i '/# Copyright/ s/$/, mschabhuettl/' ct/create_lxc.sh ct/piblocklxc.sh install/piblocklxc-install.sh misc/build.func misc/install.func | |
# Replace License URL | |
sed -i 's|https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE|https://github.com/mschabhuettl/PiBlockLXC/raw/main/LICENSE|g' ct/create_lxc.sh ct/piblocklxc.sh install/piblocklxc-install.sh misc/build.func misc/install.func | |
# Modify header_info in piblocklxc.sh | |
- name: Update header_info in piblocklxc.sh | |
run: | | |
sed -i '/^function header_info {$/,/^}$/c\function header_info {\nclear\ncat <<"EOF"\n ____ _ ____ __ __ __ _ ________\n / __ \\(_) __ )/ /___ _____/ /__/ / | |/ / ____/\n / /_/ / / __ / / __ \\/ ___/ //_/ / | / / \n / ____/ / /_/ / / /_/ / /__/ ,< / /___/ / /___ \n/_/ /_/_____/_/\\____/\\___/_/|_/_____/_/|_\\____/ \n\nEOF\n}' ct/piblocklxc.sh | |
# Update resource variables | |
sed -i 's/APP="Pihole"/APP="PiBlockLXC"/' ct/piblocklxc.sh | |
sed -i 's/var_disk="2"/var_disk="16"/' ct/piblocklxc.sh | |
sed -i 's/var_cpu="1"/var_cpu="2"/' ct/piblocklxc.sh | |
sed -i 's/var_ram="512"/var_ram="1024"/' ct/piblocklxc.sh | |
# Modify install.func for MOTD | |
- name: Update MOTD in install.func | |
run: | | |
sed -i 's|echo -e "$APPLICATION LXC provided by https://helper-scripts.com/\\n"|echo -e "$APPLICATION LXC provided by https://github.com/mschabhuettl/PiBlockLXC/\\n"|g' misc/install.func | |
# Add pihole-updatelists logic in piblocklxc-install.sh | |
- name: Add Custom Logic to piblocklxc-install.sh | |
run: | | |
sed -i '/motd_ssh/i # Prompt user to decide whether to install pihole-updatelists' install/piblocklxc-install.sh | |
sed -i '/motd_ssh/i read -r -p "Would you like to add pihole-updatelists? <Y/n> " prompt' install/piblocklxc-install.sh | |
sed -i '/motd_ssh/i if [[ -z "$prompt" || ${prompt,,} =~ ^(y|yes)$ ]]; then' install/piblocklxc-install.sh | |
sed -i '/motd_ssh/i msg_info "Installing pihole-updatelists"' install/piblocklxc-install.sh | |
sed -i '/motd_ssh/i apt-get install -y php-cli php-sqlite3 php-intl php-curl sqlite3' install/piblocklxc-install.sh | |
sed -i '/motd_ssh/i wget -O - https://raw.githubusercontent.com/jacklul/pihole-updatelists/master/install.sh | bash -s systemd' install/piblocklxc-install.sh | |
sed -i '/motd_ssh/i sed -e "/pihole updateGravity/ s/^#*/#/\" -i /etc/cron.d/pihole' install/piblocklxc-install.sh | |
sed -i '/motd_ssh/i mkdir -p /etc/systemd/system/pihole-FTL.service.d' install/piblocklxc-install.sh | |
sed -i '/motd_ssh/i echo -e "[Service]\\nExecStartPre=-/bin/sh -c \\"[ -w /etc/cron.d/pihole ] && /bin/sed -e \\"/pihole updateGravity/ s/^#*/#/\\" -i /etc/cron.d/pihole\\"" > /etc/systemd/system/pihole-FTL.service.d/override.conf' install/piblocklxc-install.sh | |
sed -i '/motd_ssh/i mkdir -p /etc/systemd/system/pihole-updatelists.timer.d' install/piblocklxc-install.sh | |
sed -i '/motd_ssh/i echo -e "[Timer]\\nRandomizedDelaySec=5m\\nOnCalendar=*-*-* 03:00:00" > /etc/systemd/system/pihole-updatelists.timer.d/override.conf' install/piblocklxc-install.sh | |
sed -i '/motd_ssh/i systemctl daemon-reload' install/piblocklxc-install.sh | |
sed -i '/motd_ssh/i systemctl restart pihole-FTL.service' install/piblocklxc-install.sh | |
sed -i '/motd_ssh/i wget -O /etc/pihole-updatelists.conf https://raw.githubusercontent.com/mschabhuettl/PiBlockLXC/main/config/pihole-updatelists.conf' install/piblocklxc-install.sh | |
sed -i '/motd_ssh/i sqlite3 /etc/pihole/gravity.db "DELETE FROM adlist"' install/piblocklxc-install.sh | |
sed -i '/motd_ssh/i sqlite3 /etc/pihole/gravity.db "DELETE FROM adlist_by_group"' install/piblocklxc-install.sh | |
sed -i '/motd_ssh/i sqlite3 /etc/pihole/gravity.db "DELETE FROM domainlist"' install/piblocklxc-install.sh | |
sed -i '/motd_ssh/i sqlite3 /etc/pihole/gravity.db "DELETE FROM domainlist_by_group"' install/piblocklxc-install.sh | |
sed -i '/motd_ssh/i pihole-updatelists' install/piblocklxc-install.sh | |
sed -i '/motd_ssh/i fi' install/piblocklxc-install.sh | |
# Clean up temporary repository | |
- name: Clean Up Temporary Repository | |
run: | | |
rm -rf tmp-original-repo | |
# Commit changes and create a Pull Request | |
- name: Commit and Create Pull Request | |
uses: peter-evans/create-pull-request@v5 | |
with: | |
branch: update-from-original-repo | |
title: "Update from Original Repository" | |
body: "Automated update from the original repository and custom modifications." |