79 lines
2.9 KiB
Bash
79 lines
2.9 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:-False}"
|
|
SECURITY_REPOS="${SECURITY_REPOS:-True}"
|
|
DEBIAN_REPOS="${DEBIAN_REPOS:-True}"
|
|
OPNSENSE_REPOS="${OPNSENSE_REPOS:-True}"
|
|
|
|
# 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 https://tea.shupogaki.org/YuruC3/Repo-IP-lists
|
|
if [[ "$EXTRA_REPOS" ]]; then
|
|
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 [[ "$SECURITY_REPOS" ]]; then
|
|
ln -s /etc/debmirror/Repo-IP-lists/SecurityMirrorListV4 /etc/debmirror/SecurityMirrorListV4
|
|
ln -s /etc/debmirror/Repo-IP-lists/SecurityMirrorListV6 /etc/debmirror/SecurityMirrorListV6
|
|
|
|
echo "05 */4 * * * /etc/debmirror/venv/bin/python3 /etc/debmirror/mainSec.py" >> /etc/crontabs/cron-jobs
|
|
fi
|
|
if [[ "$DEBIAN_REPOS" ]]; then
|
|
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
|
|
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 "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 |