= Raspberry Service designen = Am Beispiel von WPA-Ping (wird von mir '''NICHT genutzt''') Das Script sieht so aus: {{{ cat >> /usr/local/bin/wpaping << "EOFWPA" #!/bin/bash # # Loop forever doing wpa_cli SCAN commands # sleeptime=120 # number of seconds to sleep. 2 minutes (120 seconds) is a good value while [ 1 ]; do wpa_cli -i wlan0 scan sleep $sleeptime done EOFWPA }}} Der Service selber wird so gestaltet: {{{ cat >> /lib/systemd/system/wpaping.service << "EOFWPA" [Unit] Description=WPA Supplicant pinger Requires=network-online.target [Service] ExecStart=/usr/local/bin/wpaping User=root StandardInput=null StandardOutput=null StandardError=null Restart=on-failure [Install] WantedBy=multi-user.target EOFWPA }}} Um den Service dauerhaft zu starten, einfach den Standard-Weg beschreiten: {{{ systemctl daemon-reload; systemctl enable wpaping.service; systemctl start wpaping.service }}} Runlevel herausfinden: {{{ runlevel }}} Eigener Versuch: {{{ [Unit] Description=Sync Logfiles between SD Card and ramdisk Requires=var-log.mount DefaultDependencies=no After=local-fs.target Before=basic.target Conflicts=umount.target [Service] Type=oneshot RemainAfterExit=yes ExecStart=/home/hss/scripts/rsync-log-files-boot.sh ExecStop=/home/hss/scripts/rsync-log-files-shutdown.sh User=root [Install] WantedBy=multi-user.target }}} Script: {{{ #!highlight bash #!/bin/bash ### BEGIN INIT INFO # Provides: varlog # Required-Start: $local_fs # Required-Stop: $local_fs # X-Start-Before: $syslog # X-Stop-After: $syslog # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Start/stop tmpfs logfile saving and restore. ### END INIT INFO # # Increases overall system performance. # Increases the life of your SDcard by reducing filesystem IO (read/writes). # PATH=/sbin:/usr/sbin:/bin:/usr/bin varlogSave=/var/save.log/ [ ! -d $varlogSave ] && mkdir -p $varlogSave function _save() { if [ -x "$(which rsync)" ]; then rsync -a --delete /var/log/ ${varlogSave} else cp -Rpu "/var/log/*" $varlogSave fi sync } case $1 in start) echo "*** Starting tmpfs file restore: varlog." if [ -z "$(grep /var/log /proc/mounts)" ]; then echo "*** mounting /var/log" _save varlogsize=$(grep /var/log /etc/fstab|awk {'print $4'}|cut -d"=" -f2) [ -z "$varlogsize" ] && varlogsize="70M" mount -t tmpfs tmpfs /var/log -o defaults,size=$varlogsize chmod 775 /var/log fi cp -Rpu ${varlogSave}* /var/log/ ;; stop) echo "*** Stopping tmpfs file saving: varlog." _save umount -f /var/log/ ;; *) echo "Usage: $0 {start|stop}" exit 1 ;; esac exit 0 [/php] Ein weiterer Gedanke wäre noch einen Schritt weiter zu gehen und im "start" Abschnitt die letzte Zeile wie folgt abzuändern: [code] cp -Rp --attributes-only ${varlogSave}* /var/log/ }}} ---- KategorieRaspberry