Skip to content

Instantly share code, notes, and snippets.

@marvin-marvin
Last active September 12, 2021 11:04
Show Gist options
  • Save marvin-marvin/ba839de656c98fa3eb7ac5685f99327c to your computer and use it in GitHub Desktop.
Save marvin-marvin/ba839de656c98fa3eb7ac5685f99327c to your computer and use it in GitHub Desktop.
crontab
##### Crontab
#####
# don't forget to ln -s wget to path
#####
# ENV
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
# sync + apply crontab
11 * * * * /usr/bin/wget -q https://gist.githubusercontent.com/marvin-marvin/ba839de656c98fa3eb7ac5685f99327c/raw/crontab.txt -O /tmp/crontab && if [[ -s /tmp/crontab ]] ; then /usr/bin/crontab /tmp/crontab ; else : ; fi
# sync timesyncd config
02 00 * * * /usr/bin/wget -q https://gist.githubusercontent.com/marvin-marvin/44090e37edee2366d90c6a21737336ff/raw/timesyncd.conf -O /etc/systemd/timesyncd.conf
# sync dns config
02 00 * * * /usr/bin/wget -q https://gist.githubusercontent.com/marvin-marvin/0072e45e008306563ca492b140709eea/raw/resolved.conf -O /etc/systemd/resolved.conf
03 00 * * * /usr/bin/wget -q https://gist.githubusercontent.com/marvin-marvin/5980c361a2dd32033ab3483a89656406/raw/stubby.yml -O /etc/stubby/stubby.yml
* * * * * /bin/echo 'nameserver 127.0.0.1' > /etc/resolv.conf
# sync sshd config
03 00 * * * /usr/bin/wget -q https://gist.githubusercontent.com/marvin-marvin/e63d8a44091aff31b750e1114544f016/raw/sshd_config.txt -O /etc/ssh/sshd_config
# sync fail2ban configs
20 00 * * * /usr/bin/wget -q https://gist.githubusercontent.com/marvin-marvin/acc66fc20329777a724d9c837a1560da/raw/jail.local.txt -O /etc/fail2ban/jail.local
20 00 * * * /usr/bin/wget -q https://gist.githubusercontent.com/marvin-marvin/d82b2151f25960c4bbc4887cdabca41e/raw/ufw.conf -O /etc/fail2ban/action.d/ufw.conf
# sync unattended-upgrades config
05 00 * * * /usr/bin/wget -q https://gist.githubusercontent.com/marvin-marvin/1375a26336f529cdc562329e027216f4/raw/20auto-upgrades -O /etc/apt/apt.conf.d/20auto-upgrades
05 00 * * * /usr/bin/wget -q https://gist.githubusercontent.com/marvin-marvin/3d7e78a6024e7554710aca17ab7416d9/raw/50unattended-upgrades -O /etc/apt/apt.conf.d/50unattended-upgrades
# sync tmux config
08 00 * * * /usr/bin/wget -q https://gist.githubusercontent.com/marvin-marvin/c865e89e9e354ee741670f5f0750206b/raw/tmux_config -O /root/.tmux.conf
# sync tmux plugins if not already synced
@monthly /usr/bin/git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
@monthly /usr/bin/git clone https://github.com/tmux-plugins/tmux-sensible ~/.tmux/plugins/tmux-sensible
@monthly /usr/bin/git clone https://github.com/tmux-plugins/tmux-pain-control ~/.tmux/plugins/tmux-pain-control
@monthly /usr/bin/git clone https://github.com/tmux-plugins/tmux-sessionist ~/.tmux/plugins/tmux-sessionist
@monthly /usr/bin/git clone https://github.com/tmux-plugins/tmux-resurrect ~/.tmux/plugins/tmux-resurrect
@monthly /usr/bin/git clone https://github.com/tmux-plugins/tmux-online-status ~/.tmux/plugins/tmux-online-status
@monthly /usr/bin/git clone https://github.com/tmux-plugins/tmux-continuum ~/.tmux/plugins/tmux-continuum
@monthly /usr/bin/git clone https://github.com/tmux-plugins/tmux-yank ~/.tmux/plugins/tmux-yank
@monthly /usr/bin/git clone https://github.com/tmux-plugins/tmux-net-speed ~/.tmux/plugins/tmux-net-speed
@monthly /usr/bin/git clone https://github.com/tmux-plugins/tmux-cpu ~/.tmux/plugins/tmux-cpu
@monthly /usr/bin/git clone https://github.com/tmux-plugins/tmux-logging ~/.tmux/plugins/tmux-logging
# sync tmux plugins if already synced
@monthly cd ~/.tmux/plugins/tpm && /usr/bin/git fetch --all && /bin/git checkout --force "origin/master"
@monthly cd ~/.tmux/plugins/tmux-sensible && /usr/bin/git fetch --all && /bin/git checkout --force "origin/master"
@monthly cd ~/.tmux/plugins/tmux-pain-control && /usr/bin/git fetch --all && /bin/git checkout --force "origin/master"
@monthly cd ~/.tmux/plugins/tmux-sessionist && /usr/bin/git fetch --all && /bin/git checkout --force "origin/master"
@monthly cd ~/.tmux/plugins/tmux-resurrect && /usr/bin/gitfetch --all && /bin/git checkout --force "origin/master"
@monthly cd ~/.tmux/plugins/tmux-online-status && /usr/bin/git fetch --all && /bin/git checkout --force "origin/master"
@monthly cd ~/.tmux/plugins/tmux-continuum && /usr/bin/git fetch --all && /bin/git checkout --force "origin/master"
@monthly cd ~/.tmux/plugins/tmux-yank && /usr/bin/git fetch --all && /bin/git checkout --force "origin/master"
@monthly cd ~/.tmux/plugins/tmux-net-speed && /usr/bin/git fetch --all && /bin/git checkout --force "origin/master"
@monthly cd ~/.tmux/plugins/tmux-cpu && /usr/bin/git fetch --all && /bin/git checkout --force "origin/master"
@monthly cd ~/.tmux/plugins/tmux-logging && /usr/bin/git fetch --all && /bin/git checkout --force "origin/master"
# sync hosts file after boot and periodically
@reboot /usr/bin/wget -q https://gist.githubusercontent.com/marvin-marvin/def826b481c61fa743cffb60bca73e66/raw/hosts.txt -O /etc/hosts
00 */3 * * * /usr/bin/wget -q https://gist.githubusercontent.com/marvin-marvin/def826b481c61fa743cffb60bca73e66/raw/hosts.txt -O /etc/hosts
# sync ~/.ssh/config file
00 */6 * * * if [[ "$HOSTNAME" == "VPS-Dev-Go" ]] ; then /usr/bin/wget -q https://gist.githubusercontent.com/marvin-marvin/48c57ded49adba5cda7d9ef34920ac68/raw/github_key_push_master.config -O /root/.ssh/config ; else : ; fi
# sync bash
00 */6 * * * if [[ "$HOSTNAME" == "VPS-Dev-Go" ]] ; then mkdir -p ~/bash && cd ~/bash && /bin/git fetch --all && /bin/git checkout --force "origin/master" && cd ; else : ; fi
# clean up stuff after reboot
@reboot /bin/rm /root/original-ks.cfg ; /bin/rm /root/anaconda-ks.cfg ; /bin/rm /tmp/.bash*
# other fix stuff
00 * * * * /bin/chmod -R 0700 /root/.ssh
@reboot /bin/systemctl restart systemd-resolved
###### idea section
#@reboot /bin/sleep 10 && /bin/systemctl restart wg-quick@wg0
#* * * * * if [[ "$HOSTNAME" == "vps-ger-nue-kube-1" ]] ; then /bin/chown dropbox:dropbox -R /home/dropbox/Dropbox/k8s ; else : ; fi
#* * * * * if [[ "$HOSTNAME" == "vps-ger-nue-kube-1" ]] ; then sleep 10 ; /bin/chown dropbox:dropbox -R /home/dropbox/Dropbox/k8s ; else : ; fi
#* * * * * if [[ "$HOSTNAME" == "vps-ger-nue-kube-1" ]] ; then sleep 20 ; /bin/chown dropbox:dropbox -R /home/dropbox/Dropbox/k8s ; else : ; fi
#* * * * * if [[ "$HOSTNAME" == "vps-ger-nue-kube-1" ]] ; then sleep 30 ; /bin/chown dropbox:dropbox -R /home/dropbox/Dropbox/k8s ; else : ; fi
#* * * * * if [[ "$HOSTNAME" == "vps-ger-nue-kube-1" ]] ; then sleep 40 ; /bin/chown dropbox:dropbox -R /home/dropbox/Dropbox/k8s ; else : ; fi
#* * * * * if [[ "$HOSTNAME" == "vps-ger-nue-kube-1" ]] ; then sleep 50 ; /bin/chown dropbox:dropbox -R /home/dropbox/Dropbox/k8s ; else : ; fi
### if [[ "$(uname -m)" == arm* ]] ; then DO ; elif [[ "$(uname -m)" == x86_64* ]] ; then DO ; else : ; fi
### if [[ ! -z "$(command -v apt-get)" ]] ; then echo "APT" ; elif [[ ! -z "$(command -v yum)" ]] ; then echo "YUM" ; else : ; fi
#* * * * * /bin/echo 'nameserver 9.9.9.9' > /etc/resolv.conf && /bin/echo 'nameserver 1.1.1.1' >> /etc/resolv.conf
#02 01 * * * /bin/ln -sf /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf
#02 00 * * * /usr/bin/wget -q https://gist.githubusercontent.com/marvin-marvin/58dc458303656346c24bcdce9e22fbdb/raw/resolv.conf -O /etc/systemd/resolv.conf
#00 */6 * * * if [[ "$HOSTNAME" == "DevBox" ]] || [[ "$HOSTNAME" == "Raspberrypi" ]] ; then /bin/wget -q https://gist.githubusercontent.com/marvin-marvin/48c57ded49adba5cda7d9ef34920ac68/raw/github_key_devbox.config -O /root/.ssh/config ; elif [[ "$HOSTNAME" == "kube1" ]] || [[ "$HOSTNAME" == "kube2" ]] || [[ "$HOSTNAME" == "kube3" ]] ; then /bin/wget -q https://gist.githubusercontent.com/marvin-marvin/5018ad9688e3281a8860b7d33e051e40/raw/github_key_kubes.config -O /root/.ssh/config ; else : ; fi
# sync selinux disable
#15 00 * * * /bin/wget -q https://gist.githubusercontent.com/marvin-marvin/c499e9d37d06fe8c1fa1176c98928cf7/raw/selinux_config.txt -O /etc/selinux/config
# sync ntp config
#03 00 * * * /bin/wget -q https://gist.githubusercontent.com/marvin-marvin/b965718761423004343548defaf1c7c0/raw/ntp.conf -O /etc/ntp.conf ; /bin/wget -q https://gist.githubusercontent.com/marvin-marvin/dde74d69a0cd6e65116ebf0f8684d85b/raw/ntpdate.txt -O /etc/sysconfig/ntpdate
# sync yum-cron config
#05 00 * * * if [[ ! -z "$(command -v yum)" ]] ; then /bin/wget -q https://gist.githubusercontent.com/marvin-marvin/db0de3da3a3047f0bde963606c5842ee/raw/yum-cron.conf -O /etc/yum/yum-cron.conf ; else : ; fi
# sync pulseway config and merge with tokenfile
#00 */3 * * * if [[ "$HOSTNAME" == "ds-ger-bs-kube-100" ]] ; then /bin/wget -q https://gist.githubusercontent.com/marvin-marvin/485ab9222c0a892826b1a958180d07f1/raw/pulseway_config_ds.xml -O /etc/pulseway/pulseway_config.xml && /bin/cat /etc/pulseway/token /etc/pulseway/pulseway_config.xml > /etc/pulseway/out && /bin/mv /etc/pulseway/out /etc/pulseway/config.xml ; elif [[ "$HOSTNAME" == "vps-us-ny-kube-1" ]] || [[ "$HOSTNAME" == "vps-us-lax-kube-2" ]] || [[ "$HOSTNAME" == "vps-ger-nue-kube-3" ]] || [[ "$HOSTNAME" == "vps-us-chi-kube-4" ]] ; then /bin/wget -q https://gist.githubusercontent.com/marvin-marvin/d03704307bb9dfa5f8df733668e6f0df/raw/pulseway_config_vps.xml -O /etc/pulseway/pulseway_config.xml && /bin/cat /etc/pulseway/token /etc/pulseway/pulseway_config.xml > /etc/pulseway/out && /bin/mv /etc/pulseway/out /etc/pulseway/config.xml ; else : ; fi
# sync time periodically
#00 */6 * * * /usr/sbin/ntpdate -ub time.google.com && hwclock -w && timedatectl --adjust-system-clock set-local-rtc 0 >> /var/log/ntpdate.log
# sync proxy
#06 00 * * * /bin/wget -q https://gist.githubusercontent.com/marvin-marvin/24680a1331261b32522f9bde2aad19d9/raw/curlrc -O /root/.curlrc
#07 00 * * * /bin/wget -q https://gist.githubusercontent.com/marvin-marvin/24680a1331261b32522f9bde2aad19d9/raw/99HttpProxy -O /etc/apt/apt.conf.d/99HttpProxy
#08 00 * * * /bin/wget -q https://gist.githubusercontent.com/marvin-marvin/24680a1331261b32522f9bde2aad19d9/raw/proxy -O /etc/sysconfig/proxy
#09 00 * * * /bin/wget -q https://gist.githubusercontent.com/marvin-marvin/24680a1331261b32522f9bde2aad19d9/raw/proxy.sh -O /etc/profile.d/proxy.sh && /bin/chmod +x /etc/profile.d/proxy.sh
#10 00 * * * /bin/wget -q https://gist.githubusercontent.com/marvin-marvin/24680a1331261b32522f9bde2aad19d9/raw/wgetrc -O /root/.wgetrc
#11 00 * * * /bin/wget -q https://gist.githubusercontent.com/marvin-marvin/24680a1331261b32522f9bde2aad19d9/raw/wgetrc -O /etc/wgetrc
#12 00 * * * /bin/wget -q https://gist.githubusercontent.com/marvin-marvin/24680a1331261b32522f9bde2aad19d9/raw/yum.conf -O /etc/yum.conf
#13 00 * * * /bin/grep -qxF '#export ftp_proxy=ftp://192.168.1.201:3128' /etc/environment || /bin/echo '#export ftp_proxy=ftp://192.168.1.201:3128' >> /etc/environment
#14 00 * * * /bin/grep -qxF '#export http_proxy=http://192.168.1.201:3128' /etc/environment || /bin/echo '#export http_proxy=http://192.168.1.201:3128' >> /etc/environment
#15 00 * * * /bin/grep -qxF '#export https_proxy=https://192.168.1.201:3128' /etc/environment || /bin/echo '#export https_proxy=https://192.168.1.201:3128' >> /etc/environment
#16 00 * * * /bin/grep -qxF '#export socks_proxy=https://192.168.1.201:3128' /etc/environment || /bin/echo '#export socks_proxy=https://192.168.1.201:3128' >> /etc/environment
# Auto pull github repos
#00 */6 * * * if [[ "$HOSTNAME" == "vps-ger-fra-1" ]] ; then mkdir -p /root/bash-acc && cd /root/bash-acc && /bin/git fetch --all && /bin/git checkout --force "origin/master" && /bin/chmod -R 0700 /root/.ssh && cd ; else : ; fi
#00 */6 * * * if [[ "$HOSTNAME" == "vps-ger-fra-1" ]] || [[ "$HOSTNAME" == "ds-ger-bs-kube-100" ]] ; then mkdir -p /root/bash-keys && cd /root/bash-keys && /bin/git fetch --all && /bin/git checkout --force "origin/master" && /bin/chmod -R 0700 /root/bash-keys && cd ; else : ; fi
#00 */6 * * * if [[ "$HOSTNAME" == "vps-ger-fra-1" ]] ; then mkdir -p /root/ssh-find-agent && cd /root/ssh-find-agent && /bin/git fetch --all && /bin/git checkout --force "origin/master" && cd ; else : ; fi
#00 */3 * * * if [[ "$HOSTNAME" == "ds-ger-bs-kube-100" ]] ; then mkdir -p /root/kubeadm-cfg && cd /root/kubeadm-cfg && /bin/git fetch --all && /bin/git checkout --force "origin/master" && cd ; else : ; fi
#15 */12 * * * /bin/wget -q https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py -O /root/speedtest && /bin/chmod +x /root/speedtest
#16 */12 * * * /bin/wget -q https://gist.githubusercontent.com/marvin-marvin/a1d56eb933d8cc8a6d30d812764020b9/raw/dyndns_allow.sh -O /root/dyndns_allow.sh && /bin/chmod +x /root/dyndns_allow.sh
#*/30 * * * * if [[ "$HOSTNAME" == "ds-ger-bs-kube-100" ]] ; then mkdir -p /root/k8s-tmp && cd /root/k8s-tmp && /bin/git add -A && /bin/git commit -m "update" && /bin/git push --force origin master && cd ; elif [[ "$HOSTNAME" == "vps-ger-fra-1" ]] ; then mkdir -p /root/k8s-tmp && cd /root/k8s-tmp && /bin/git fetch --all && /bin/git checkout --force "origin/master" && cd ; else : ; fi
# push repos
#*/45 * * * * if [[ "$HOSTNAME" == "ds-ger-bs-kube-100" ]] ; then mkdir -p /root/k8s-cfg && cd /root/k8s-cfg && /bin/git add -A && /bin/git commit -m "update" && /bin/git push --force origin master && cd ; elif [[ "$HOSTNAME" == "vps-ger-fra-1" ]] || [[ "$HOSTNAME" == "vps-us-ny-kube-1" ]] || [[ "$HOSTNAME" == "vps-us-lax-kube-2" ]] || [[ "$HOSTNAME" == "vps-ger-nue-kube-3" ]] || [[ "$HOSTNAME" == "vps-us-chi-kube-4" ]] ; then mkdir -p /root/k8s-cfg && cd /root/k8s-cfg && /bin/git fetch --all && /bin/git checkout --force "origin/master" && cd ; else : ; fi
#* * * * * [ -f /root/dead.letter ] && /bin/mv /root/dead.letter /tmp && /bin/mv /tmp/dead.letter /tmp/dead.letter_`date +\%F-\%H:\%M` ; [ -f /tmp/exec.sh ] && /bin/rm /tmp/exec.sh
# dyndns stuff
#* * * * * echo "`date` `/root/dyndns_allow.sh`" >> /var/log/dyndns_run
#@reboot /bin/rm /var/log/dyn*
# Security updates photon OS
#04 00 * * * if [[ "$(uname -v)" == *photon* ]] ; then /bin/tdnf upgrade --security -y ; else : ; fi
# EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment