#!/usr/bin/sh #---------------------------------------------------------------------------------- # /var/install/bin/nextcloud-pre-view-log - view log file # # Copyright (c) 2013-2025 The Eisfair Team, team(at)eisfair(dot)org # # Creation: 2013-02-11 jed # Last Update: $Id$ # # 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 # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. #---------------------------------------------------------------------------------- # read eislib etc. . /var/install/include/eislib pgmname=`basename $0` module_name="`echo "${pgmname}" | cut -d- -f1 | cut -d. -f1`" # set platform specific parameters nextcloud_path=/var/${module_name} configfile=/etc/config.d/${module_name} logdir=/var/log NEXTCLOUD_LOG_TYPE=`grep -m 1 "^NEXTCLOUD_LOG_TYPE" ${configfile} | sed 's/^[A-Z0-9_]* *= *.\([a-z]*\).*$/\1/'` if [ -z "${NEXTCLOUD_LOG_TYPE}" ] then NEXTCLOUD_LOG_TYPE='file' fi if [ -n "${NEXTCLOUD_DATA_DIR}" ] then nextcloud_path="`echo "${NEXTCLOUD_DATA_DIR}" | sed 's#[/ ]*$##'`" fi nextcloud_logpath=${nextcloud_path}/log case ${NEXTCLOUD_LOG_TYPE} in syslog ) log_file=${logdir}/messages log_tmpfile=${logdir}/${module_name}.log if [ -s "${log_file}" ] then grep -h -i " ${module_name}[([):]" ${log_file} > ${log_tmpfile} if [ ! -s "${log_tmpfile}" ] then echo "Info: Nothing has been logged until now." > ${log_tmpfile} fi else echo "Warning: Logfile ${log_file} not found or empty!" > ${log_tmpfile} fi ;; *|file ) if [ ! -L ${logdir}/${module_name}.log ] then # not a symbolic link, create backup mv ${logdir}/${module_name}.log ${logdir}/${module_name}-${EISDATE}.log fi create symbolic link ln -sf ${nextcloud_logpath}/${module_name}.log ${logdir}/${module_name}.log ;; esac exit 0