95 lines
3.7 KiB
Bash
95 lines
3.7 KiB
Bash
#!/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
|
|
if [[ "$EXTRA_REPOS" ]]; then
|
|
touch /etc/debmirror/Repo-IP-lists/CustomMirrorListV{4,6}
|
|
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
|
|
if [[ "$PROXMOX_REPOS" ]]; then
|
|
touch /etc/debmirror/Repo-IP-lists/ProxmoxMirrorListV{4,6}
|
|
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
|
|
if [[ "$DOCKER_REPOS" ]]; then
|
|
touch /etc/debmirror/Repo-IP-lists/DockerMirrorListV{4,6}
|
|
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
|
|
if [[ "$DEBIAN_REPOS" ]]; then
|
|
touch /etc/debmirror/Repo-IP-lists/DebianMirrorListV{4,6}
|
|
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
|
|
if [[ "$OPNSENSE_REPOS" ]]; then
|
|
touch /etc/debmirror/Repo-IP-lists/OPNsenseMIrrorListV{4,6}
|
|
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 |