mirror of
https://github.com/nextcloud/nextcloudpi.git
synced 2026-01-10 15:12:01 -03:30
log all NCP actions to /var/log/ncp.log
This commit is contained in:
parent
51b1e5dd52
commit
f8381f42cd
@ -105,13 +105,26 @@ function is_active_script()
|
||||
)
|
||||
}
|
||||
|
||||
function run_and_log()
|
||||
{
|
||||
local SCRIPT=$1
|
||||
touch /var/log/ncp.log
|
||||
chmod 640 /var/log/ncp.log
|
||||
chown root:www-data /var/log/ncp.log
|
||||
echo -e "[ $( basename "$SCRIPT" .sh ) ]" >> /var/log/ncp.log
|
||||
configure 2>&1 | tee -a /var/log/ncp.log
|
||||
local RET="${PIPESTATUS[0]}"
|
||||
echo "" >> /var/log/ncp.log
|
||||
return "$RET"
|
||||
}
|
||||
|
||||
function launch_script()
|
||||
{
|
||||
(
|
||||
local SCRIPT=$1
|
||||
source ./"$SCRIPT"
|
||||
set +x
|
||||
configure
|
||||
run_and_log "$SCRIPT"
|
||||
)
|
||||
}
|
||||
|
||||
@ -140,7 +153,7 @@ function configure_script()
|
||||
printf '\033[2J' && tput cup 0 0 # clear screen, don't clear scroll, cursor on top
|
||||
echo -e "Launching $( basename "$SCRIPT" .sh )"
|
||||
set +x
|
||||
configure
|
||||
run_and_log "$SCRIPT"
|
||||
return 0
|
||||
)
|
||||
}
|
||||
|
||||
@ -45,7 +45,7 @@ function pingClient()
|
||||
*/
|
||||
function follow($file)
|
||||
{
|
||||
$size = 0;
|
||||
$size = filesize($file);
|
||||
while (true)
|
||||
{
|
||||
if ( !file_exists($file) )
|
||||
@ -78,7 +78,8 @@ function follow($file)
|
||||
|
||||
session_write_close();
|
||||
echo str_pad('',1024*1024*4); // make sure the browser buffer becomes full
|
||||
follow( '/run/ncp.log' );
|
||||
touch( '/var/log/ncp.log' );
|
||||
follow( '/var/log/ncp.log' );
|
||||
|
||||
// License
|
||||
//
|
||||
|
||||
@ -32,8 +32,6 @@ $(document).ready(function(){
|
||||
$('button').prop('disabled', true);
|
||||
addNotification( action, 'gray-bg' ) ;
|
||||
|
||||
logOutput( '\n[ ' + action + ' ]' + '\n' );
|
||||
|
||||
$.post('../ncp-launcher.php',
|
||||
{ action:'launch',
|
||||
ref: action,
|
||||
|
||||
@ -107,17 +107,7 @@ DIR=/usr/local/etc/nextcloudpi-config.d
|
||||
test -f $DIR/$1 || { echo "File not found"; exit 1; }
|
||||
source /usr/local/etc/library.sh
|
||||
cd $DIR
|
||||
touch /run/ncp.log
|
||||
chmod 640 /run/ncp.log
|
||||
chown root:www-data /run/ncp.log
|
||||
launch_script $1 &> /run/ncp.log
|
||||
RET=$?
|
||||
|
||||
# clean log for the next PHP backend call to start clean,
|
||||
# but wait until everything from current execution is read
|
||||
sleep 0.5 && echo "" > /run/ncp.log
|
||||
|
||||
exit $RET
|
||||
launch_script $1
|
||||
EOF
|
||||
chmod 700 /home/www/ncp-launcher.sh
|
||||
echo "www-data ALL = NOPASSWD: /home/www/ncp-launcher.sh , /sbin/halt" >> /etc/sudoers
|
||||
|
||||
11
update.sh
11
update.sh
@ -249,6 +249,17 @@ EOF
|
||||
sed -i 's|^ServerSignature .*|ServerSignature Off|' /etc/apache2/conf-enabled/security.conf
|
||||
sed -i 's|^ServerTokens .*|ServerTokens Prod|' /etc/apache2/conf-enabled/security.conf
|
||||
|
||||
# upgrade launcher after logging improvements
|
||||
cat > /home/www/ncp-launcher.sh <<'EOF'
|
||||
#!/bin/bash
|
||||
DIR=/usr/local/etc/nextcloudpi-config.d
|
||||
test -f $DIR/$1 || { echo "File not found"; exit 1; }
|
||||
source /usr/local/etc/library.sh
|
||||
cd $DIR
|
||||
launch_script $1
|
||||
EOF
|
||||
chmod 700 /home/www/ncp-launcher.sh
|
||||
|
||||
} # end - only live updates
|
||||
|
||||
exit 0
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user