$OpenBSD: patch-daily_sh,v 1.11 2016/06/20 15:12:42 sthen Exp $

- use ksh
- patch php binary name
- avoid ${cnf,,} bashism (converts to lowercase); actually the
result was being ignored anyway

--- daily.sh.orig	Mon Jun 20 14:49:32 2016
+++ daily.sh	Mon Jun 20 14:50:42 2016
@@ -1,4 +1,4 @@
-#!/usr/bin/env bash
+#!/bin/ksh
 # Copyright (C) 2015 Daniel Preussker, QuxLabs UG <preussker@quxlabs.com>
 # This program is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -23,7 +23,7 @@ arg="$1"
 status_run() {
     printf "%-50s" "$1"
     echo "$1" >> logs/daily.log
-    tmp=$(bash -c "$2" 2>&1)
+    tmp=$(sh -c "$2" 2>&1)
     ex=$?
     echo "$tmp" >> logs/daily.log
     echo "Returned: $ex" >> logs/daily.log
@@ -32,7 +32,7 @@ status_run() {
 }
 
 if [ -z "$arg" ]; then
-    up=$(php daily.php -f update >&2; echo $?)
+    up=$(%PHP% daily.php -f update >&2; echo $?)
     if [ "$up" -eq 0 ]; then
         $0 no-code-update
         exit
@@ -43,9 +43,9 @@ if [ -z "$arg" ]; then
         # Update to last Tag
         status_run 'Updating to latest release' 'git fetch --tags && git checkout $(git describe --tags $(git rev-list --tags --max-count=1))'
     fi
-
-    cnf=$(echo $(grep '\[.distributed_poller.\]' config.php | egrep -v -e '^//' -e '^#' | cut -d = -f 2 | sed 's/;//g'))
-    cnf=${cnf,,}
+ 
+     
+    cnf=$(awk '/^\$config\[.distributed_poller.\]/ {gsub(" ", ""); FS="[=;]"; print tolower($2)}' config.php)
     if [ -z "$cnf" ] || [ "$cnf" == "0" ] || [ "$cnf" == "false" ]; then
         # Call ourself again in case above pull changed or added something to daily.sh
         $0 post-pull
@@ -55,27 +55,27 @@ else
         no-code-update)
             # Updates of the code are disabled, just check for schema updates
             # and clean up the db.
-            status_run 'Updating SQL-Schema' 'php includes/sql-schema/update.php'
+            status_run 'Updating SQL-Schema' '%PHP% includes/sql-schema/update.php'
             status_run 'Cleaning up DB' "$0 cleanup"
         ;;
         post-pull)
             # List all tasks to do after pull in the order of execution
-            status_run 'Updating SQL-Schema' 'php includes/sql-schema/update.php'
+            status_run 'Updating SQL-Schema' '%PHP% includes/sql-schema/update.php'
             status_run 'Updating submodules' "$0 submodules"
             status_run 'Cleaning up DB' "$0 cleanup"
             status_run 'Fetching notifications' "$0 notifications"
         ;;
         cleanup)
             # DB-Cleanups
-            php daily.php -f syslog
-            php daily.php -f eventlog
-            php daily.php -f authlog
-            php daily.php -f perf_times
-            php daily.php -f callback
-            php daily.php -f device_perf
-            php daily.php -f purgeusers
-            php daily.php -f bill_data
-            php daily.php -f alert_log
+            %PHP% daily.php -f syslog
+            %PHP% daily.php -f eventlog
+            %PHP% daily.php -f authlog
+            %PHP% daily.php -f perf_times
+            %PHP% daily.php -f callback
+            %PHP% daily.php -f device_perf
+            %PHP% daily.php -f purgeusers
+            %PHP% daily.php -f bill_data
+            %PHP% daily.php -f alert_log
         ;;
         submodules)
             # Init+Update our submodules
@@ -84,7 +84,7 @@ else
         ;;
         notifications)
             # Get notifications
-            php daily.php -f notifications
+            %PHP% daily.php -f notifications
         ;;
     esac
 fi
