Files

101 lines
4.0 KiB
Bash
Raw Permalink Normal View History

#!/bin/sh
set -e
# Default to 1600 if not provided
PUID="${PUID:-1600}"
PGID="${PGID:-1600}"
USER="${USER:-muyu}"
GROUP="${USER:-muyu}"
CHOWNPATH="/etc/debmirror"
EXTRA_REPOS="${EXTRA_REPOS:-True}"
PROXMOX_REPOS="${PROXMOX_REPOS:-True}"
DOCKER_REPOS="${DOCKER_REPOS:-True}"
DEBIAN_REPOS="${DEBIAN_REPOS:-True}"
OPNSENSE_REPOS="${OPNSENSE_REPOS:-True}"
THE_REPO="${THE_REPO:-https://tea.shupogaki.org/YuruC3/Repo-IP-lists}"
# Create group if missing
if ! getent group "$GROUP" >/dev/null 2>&1; then
addgroup -g "$PGID" "$GROUP"
fi
# Create user if missing
if ! id -u "$USER" >/dev/null 2>&1; then
adduser -D -u "$PUID" -G "$GROUP" "$USER"
fi
# Prepare cron file
touch /etc/crontabs/cron-jobs
# Create symlinks based on what is passed
# Also add cronjobs when applicable
git clone $THE_REPO
2026-01-25 00:04:29 +01:00
if [ "$EXTRA_REPOS" = true ]; then
touch /etc/debmirror/Repo-IP-lists/CustomMirrorListV4
touch /etc/debmirror/Repo-IP-lists/CustomMirrorListV6
ln -s /etc/debmirror/Repo-IP-lists/CustomMirrorListV4 /etc/debmirror/CustomMirrorListV4
ln -s /etc/debmirror/Repo-IP-lists/CustomMirrorListV6 /etc/debmirror/CustomMirrorListV6
# echo "00 */4 * * * /etc/debmirror/venv/bin/python3 /etc/debmirror/mainCustom.py" >> /etc/crontabs/cron-jobs
fi
2026-01-25 00:04:29 +01:00
if [ "$PROXMOX_REPOS" = true ]; then
touch /etc/debmirror/Repo-IP-lists/ProxmoxMirrorListV4
touch /etc/debmirror/Repo-IP-lists/ProxmoxMirrorListV6
ln -s /etc/debmirror/Repo-IP-lists/ProxmoxMirrorListV4 /etc/debmirror/ProxmoxMirrorListV4
ln -s /etc/debmirror/Repo-IP-lists/ProxmoxMirrorListV6 /etc/debmirror/ProxmoxMirrorListV6
# echo "05 */4 * * * /etc/debmirror/venv/bin/python3 /etc/debmirror/mainSec.py" >> /etc/crontabs/cron-jobs
fi
2026-01-25 00:04:29 +01:00
if [ "$DOCKER_REPOS" = true ]; then
touch /etc/debmirror/Repo-IP-lists/DockerMirrorListV4
touch /etc/debmirror/Repo-IP-lists/DockerMirrorListV6
ln -s /etc/debmirror/Repo-IP-lists/DockerMirrorListV4 /etc/debmirror/DockerMirrorListV4
ln -s /etc/debmirror/Repo-IP-lists/DockerMirrorListV6 /etc/debmirror/DockerMirrorListV6
# echo "05 */4 * * * /etc/debmirror/venv/bin/python3 /etc/debmirror/mainSec.py" >> /etc/crontabs/cron-jobs
fi
2026-01-25 00:04:29 +01:00
if [ "$DEBIAN_REPOS" = true ]; then
touch /etc/debmirror/Repo-IP-lists/DebianMirrorListV4
touch /etc/debmirror/Repo-IP-lists/DebianMirrorListV6
ln -s /etc/debmirror/Repo-IP-lists/DebianMirrorListV4 /etc/debmirror/DebianMirrorListV4
ln -s /etc/debmirror/Repo-IP-lists/DebianMirrorListV6 /etc/debmirror/DebianMirrorListV6
# echo "10 */4 * * * /etc/debmirror/venv/bin/python3 /etc/debmirror/mainDocker.py" >> /etc/crontabs/cron-jobs
fi
2026-01-25 00:04:29 +01:00
if [ "$OPNSENSE_REPOS" = true ]; then
touch /etc/debmirror/Repo-IP-lists/OPNsenseMirrorListV4
touch /etc/debmirror/Repo-IP-lists/OPNsenseMirrorListV6
ln -s /etc/debmirror/Repo-IP-lists/OPNsenseMirrorListV4 /etc/debmirror/OPNsenseMirrorListV4
ln -s /etc/debmirror/Repo-IP-lists/OPNsenseMirrorListV6 /etc/debmirror/OPNsenseMirrorListV6
# echo "15 */4 * * * /etc/debmirror/venv/bin/python3 /etc/debmirror/mainOPNsense.py" >> /etc/crontabs/cron-jobs
fi
echo "00 */4 * * * /etc/debmirror/venv/bin/python3 /etc/debmirror/main.py" >> /etc/crontabs/cron-jobs
echo "30 */4 * * * /bin/sh /etc/debmirror/gitPush.sh" >> /etc/crontabs/cron-jobs
# Configure the crontab to work
chmod 0644 /etc/crontabs/cron-jobs
crontab /etc/crontabs/cron-jobs
# Fix permissions
chown -R "$PUID:$PGID" "$CHOWNPATH"
# Drop privileges & run command
exec su-exec "$PUID:$PGID" "$@"
# # python
# 20 */4 * * * /etc/debmirror/venv/bin/python3 /etc/debmirror/mainOPNsense.py
# 25 */4 * * * /etc/debmirror/venv/bin/python3 /etc/debmirror/mainDocker.py
# # 20 19 * * * /etc/debmirror/venv/bin/python3 /etc/debmirror/mainOPNsense.py
# # 25 19 * * * /etc/debmirror/venv/bin/python3 /etc/debmirror/mainDocker.py
# #*/3 * * * * /etc/debmirror/venv/bin/python3 /etc/debmirror/mainDocker.py
# #*/3 * * * * /etc/debmirror/venv/bin/python3 /etc/debmirror/mainOPNsense.py
# # git push
# 30 */4 * * * /bin/sh /etc/debmirror/gitPush.sh
# #*/1 * * * * /bin/sh /etc/debmirror/gitPush.sh