diff options
| author | grothedev <grothedev@gmail.com> | 2021-08-05 11:42:21 -0500 |
|---|---|---|
| committer | grothedev <grothedev@gmail.com> | 2021-08-05 11:42:21 -0500 |
| commit | 35fdfb2f5df7d542c0a78d6ab3ffc24deb6ca78d (patch) | |
| tree | 94a0f5f329843807fc7fae47ab77f2ab87790be5 | |
| parent | 7939f26645643dfa10f9a2189b509298bf165948 (diff) | |
added systemd services and host update script
| -rw-r--r-- | datasync.path | 15 | ||||
| -rw-r--r-- | datasync.service | 12 | ||||
| -rw-r--r-- | update-hosts.service | 10 | ||||
| -rwxr-xr-x | update_hosts | 16 |
4 files changed, 53 insertions, 0 deletions
diff --git a/datasync.path b/datasync.path new file mode 100644 index 0000000..db6bc08 --- /dev/null +++ b/datasync.path @@ -0,0 +1,15 @@ +[Unit] +Wants=datasync.service + +[Path] +PathModified=/home/thomas/doc/blog/ +PathModified=/home/thomas/img/ +PathModified=/home/thomas/_journal +PathModified=/home/thomas/lmms/projects/ +PathModified=/home/thomas/do +PathModified=/home/thomas/_poetry +PathModified=/home/thomas/aud/me/fragments-album-forreal-2018/ +Unit=datasync.service + +[Install] +WantedBy=datasync.service diff --git a/datasync.service b/datasync.service new file mode 100644 index 0000000..3d7de2a --- /dev/null +++ b/datasync.service @@ -0,0 +1,12 @@ +[Unit] +Description=backs up commonly modified files +Requires=network-online.target +After=multi-user.target + +[Service] +Type=simple +#ExecStartPre=/bin/sleep 45 +ExecStart=/usr/local/bin/syncdata +User=thomas +Restart=on-failure +RestartSec=120s diff --git a/update-hosts.service b/update-hosts.service new file mode 100644 index 0000000..6280cf5 --- /dev/null +++ b/update-hosts.service @@ -0,0 +1,10 @@ +[Unit] +Description=updates /etc/hosts with my custom hosts +Requires=network-online.target +After=multi-user.target + +[Service] +Type=simple +#ExecStartPre=/bin/sleep 45 +ExecStart=sudo /usr/local/bin/update_hosts +User=root diff --git a/update_hosts b/update_hosts new file mode 100755 index 0000000..745eb68 --- /dev/null +++ b/update_hosts @@ -0,0 +1,16 @@ +#!/bin/bash + +# this script updates hosts in /etc/hosts +# currently the only applicable host is my homeserver (local or remote ip) + +localcheck=`nmap -sn 192.168.1.0/24 | grep debian` + +if [[ $localcheck ]]; then + hb_ip=`echo $localcheck | sed 's/.*(\(.*\))/\1/g'` +else + hb_ip=`ping grothe.ddns.net -c 1 | sed 's/bytes from.*(\(.*\)).*/\1/g'` +fi + +sed -i 's/'${hb_ip}'.*//g' +echo '${hb_ip} hb' >> /etc/hosts + |
