2016-10-14 12:48:55 +00:00

97 lines
3.4 KiB
Plaintext

$OpenBSD: patch-daily_sh,v 1.13 2016/10/14 12:48:55 sthen Exp $
- use ksh
- patch php binary name
- avoid ${cnf,,} bashism (converts to lowercase); actually the
result was being ignored anyway
--- daily.sh.orig Fri Oct 14 13:25:19 2016
+++ daily.sh Fri Oct 14 13:32:38 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
@@ -55,11 +55,7 @@ if [ -z "$arg" ]; then
fi
cnf=$(echo $(grep '\[.distributed_poller.\]' config.php | egrep -v -e '^//' -e '^#' | cut -d = -f 2 | sed 's/;//g'))
- if ((${BASH_VERSINFO[0]} < 4)); then
- cnf=`echo $cnf|tr [:upper:] [:lower:]`
- else
- cnf=${cnf,,}
- fi
+ cnf=`echo $cnf|tr [:upper:] [:lower:]`
if [ -z "$cnf" ] || [ "$cnf" == "0" ] || [ "$cnf" == "false" ]; then
# Call ourself again in case above pull changed or added something to daily.sh
@@ -70,28 +66,28 @@ 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)
# 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 rrd_purge
+ %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 rrd_purge
;;
submodules)
# Init+Update our submodules
@@ -100,7 +96,7 @@ else
;;
notifications)
# Get notifications
- php daily.php -f notifications
+ %PHP% daily.php -f notifications
;;
esac
fi