Project

General

Profile

Bug #77089

Fix isues with init/shutdown scripts

Added by axc27 - almost 3 years ago. Updated over 2 years ago.

Status:
Done
Priority:
No priority
Assignee:
Waqar Ahmed
Category:
Middleware
Target version:
Seen in:
Severity:
Medium
Reason for Closing:
Reason for Blocked:
Needs QA:
No
Needs Doc:
No
Needs Merging:
No
Needs Automation:
No
Support Suite Ticket:
n/a
Hardware Configuration:
ChangeLog Required:
No

Description

init scripts added via web interface are inconsistent, shutdown scripts or commands are not executed at all.

I just switched back from NAS4Free to FreeNAS (11.2) with a fresh install.
After I had troubles with my init and shutdown scripts for some time now, I started some systematic investigations.
First, In updated to the last stable 11.2-U2, as it mentioning some user interface fixes concerning the editing of init scripts (and yes, I stumbled across these editing problems before as well).

current system:
FreeNAS-11.2-U2
(Build Date: Feb 14, 2019 20:8)

testing local commands (5 pre- post-init and shutdown commands, added the command five times as individual tasks):

touch /mnt/red1/NASData/test_scripts/`date '+%Y%m%d_%H-%M-%S'`_test_command_pre01
touch /mnt/red1/NASData/test_scripts/`date '+%Y%m%d_%H-%M-%S'`_test_command_post01
touch /mnt/red1/NASData/test_scripts/`date '+%Y%m%d_%H-%M-%S'`_test_command_shut01

-rw-r--r--  1 root  wheel    0 Feb 24 20:12 20190224_20-12-31_test_command_pre01
-rw-r--r--  1 root  wheel    0 Feb 24 20:12 20190224_20-12-31_test_command_pre02
-rw-r--r--  1 root  wheel    0 Feb 24 20:12 20190224_20-12-31_test_command_pre03
-rw-r--r--  1 root  wheel    0 Feb 24 20:12 20190224_20-12-31_test_command_pre04
-rw-r--r--  1 root  wheel    0 Feb 24 20:12 20190224_20-12-31_test_command_pre05
-rw-r--r--  1 root  wheel    0 Feb 24 20:12 20190224_20-12-38_test_command_post01
-rw-r--r--  1 root  wheel    0 Feb 24 20:12 20190224_20-12-38_test_command_post02
-rw-r--r--  1 root  wheel    0 Feb 24 20:12 20190224_20-12-38_test_command_post03
-rw-r--r--  1 root  wheel    0 Feb 24 20:12 20190224_20-12-38_test_command_post04
-rw-r--r--  1 root  wheel    0 Feb 24 20:12 20190224_20-12-38_test_command_post05

System does execute all five pre- and post-init commands.
No shutdown commands are executed (or cannot write on disk).
It is the same command, just set to run at shutdown and name the file "_shu" for shutdown. Hence, the command is correct and should work.

next I tested local scripts doing essentially the same, touching files (again 5 pre- post-init and shutdown scripts):

/mnt/red1/NASData/test_scripts/script_preinit_01.sh
/mnt/red1/NASData/test_scripts/script_postinit_01.sh
/mnt/red1/NASData/test_scripts/script_shutdown_01.sh

scripts touch a file with date and their filename:

#!/bin/bash
FILENAME=${0##*/}
touch /mnt/red1/NASData/test_scripts/`date '+%Y%m%d_%H-%M-%S'`_test_$FILENAME

-rw-r--r--  1 root  wheel    0 Feb 24 20:46 20190224_20-46-56_test_script_preinit_01.sh
-rw-r--r--  1 root  wheel    0 Feb 24 20:46 20190224_20-46-56_test_script_preinit_02.sh
-rw-r--r--  1 root  wheel    0 Feb 24 20:46 20190224_20-46-56_test_script_preinit_03.sh
-rw-r--r--  1 root  wheel    0 Feb 24 20:46 20190224_20-46-56_test_script_preinit_04.sh
-rw-r--r--  1 root  wheel    0 Feb 24 20:46 20190224_20-46-56_test_script_preinit_05.sh
-rw-r--r--  1 root  wheel    0 Feb 24 20:47 20190224_20-47-03_test_script_postinit_01.sh
-rw-r--r--  1 root  wheel    0 Feb 24 20:47 20190224_20-47-03_test_script_postinit_02.sh
-rw-r--r--  1 root  wheel    0 Feb 24 20:47 20190224_20-47-03_test_script_postinit_03.sh
-rw-r--r--  1 root  wheel    0 Feb 24 20:47 20190224_20-47-03_test_script_postinit_04.sh
-rw-r--r--  1 root  wheel    0 Feb 24 20:47 20190224_20-47-03_test_script_postinit_05.sh

does execute all five pre- and post-init commands.
does not execute the shutdown commands (or cannot read/write on disk)

To remove mounted pools from the equation, I then touched files on a remote server
(passwordless ssh to second server, in this case 2 pre- post-init and shutdown commands):

ssh admin@secondserver "touch /volume2/NASData/script/test/`date '+%Y%m%d_%H-%M-%S'`_test_command_pre01" 
ssh admin@secondserver "touch /volume2/NASData/script/test/`date '+%Y%m%d_%H-%M-%S'`_test_command_post01" 
ssh admin@secondserver "touch /volume2/NASData/script/test/`date '+%Y%m%d_%H-%M-%S'`_test_command_shut01" 

-rwxrwxrwx+ 1 admin users 0 Feb 24 21:40 20190224_21-40-55_test_command_pre01
-rwxrwxrwx+ 1 admin users 0 Feb 24 21:41 20190224_21-41-03_test_command_post01

only first (of two in this case) pre- and post-init,
no shutdown command issued...

Once again is the same command, just set to name the file "01" in the first and "02" in the second run. Hence, the command is correct and should work.

Summary:
Running pre- and post-init commands is not consistent. The first set was nicely executed. For the ssh commands, only the first of two commands was executed.

I was not able to get any shutdown commands running, even though I think I had it setup in a way that one of the commands worked a few weeks ago... But I was not able to recreate that now during the systematic testing.

This is quite annoying, as I am used to do some maintenance when switching my server off (does not run 24/7 but is switched off regularly via scripts after sufficient idle time).

/axc27


Related issues

Related to FreeNAS - Bug #80679: Init/Shutdown scripts should have tooltip and note in guide about sh/zshClosed

History

#1 Updated by Dru Lavigne almost 3 years ago

  • Category changed from OS to Middleware
  • Assignee changed from Release Council to William Grzybowski

#2 Updated by William Grzybowski almost 3 years ago

  • Assignee changed from William Grzybowski to Waqar Ahmed
  • Target version changed from Backlog to 11.2-U3
  • Severity changed from New to Medium

#4 Updated by Waqar Ahmed almost 3 years ago

  • Status changed from Unscreened to In Progress

#5 Updated by Bug Clerk almost 3 years ago

  • Status changed from In Progress to Ready for Testing

#7 Updated by Dru Lavigne almost 3 years ago

  • Subject changed from init/shutdown scripts inconsistent / not working to IFix isues with nit/shutdown scripts
  • Needs Doc changed from Yes to No
  • Needs Merging changed from Yes to No

#9 Updated by Dru Lavigne almost 3 years ago

  • Subject changed from IFix isues with nit/shutdown scripts to Fix isues with init/shutdown scripts

#12 Avatar?id=55038&size=24x24 Updated by Zackary Welch over 2 years ago

  • Status changed from Ready for Testing to Passed Testing
  • Needs QA changed from Yes to No

Confirmed fixed in 11.2-U3 (new UI). I verified his scripts work and run at the right time. I also tested "&&", "||", "for" and "if" statements and they worked fine.

#13 Updated by Dru Lavigne over 2 years ago

  • Status changed from Passed Testing to Done

#14 Avatar?id=55038&size=24x24 Updated by Zackary Welch over 2 years ago

  • Status changed from Done to Failed Testing

Oops, shouldn't have passed this. Upon retesting on a related ticket I found this actually fails for the following two commands, which work fine in the shell but fail with errors (I wish I could copy the errors, but although they appear in the shell during shutdown, they aren't written to a log file and I can't copy them during the short time interval I can see them). They're both run during shutdown, but that doesn't matter.

for i in `seq 1 10`; echo $i >> /mnt/testpool/testfile_pre; sleep 5

and
if [ `expr $RANDOM % 2` = 0 ]; then echo TRUE >> /mnt/testpool/testfile; else echo FALSE >> /mnt/testpool/testfile; fi; sleep 5

Seems there's an issue with 'sh' running these although 'zsh' is the default shell. This could be a separate ticket.

#15 Updated by Waqar Ahmed over 2 years ago

  • Status changed from Failed Testing to Blocked
  • Reason for Blocked set to Waiting for feedback

Could you please tell me which shell you are using ?

#16 Updated by Waqar Ahmed over 2 years ago

Uh oh, i missed your last line :D Yes this indeed wouldn't work with sh :P - Please mark this as passed testing then if you have no other issues - We should however probably reflect this in docs if we don't already that the commands are run with sh

#17 Avatar?id=55038&size=24x24 Updated by Zackary Welch over 2 years ago

  • Status changed from Blocked to Passed Testing
  • Reason for Blocked deleted (Waiting for feedback)

Making docs ticket to reflect sh/zsh discrepancy, but it does seem complex shell commands are recognized and work.

#18 Updated by Dru Lavigne over 2 years ago

  • Needs Doc changed from No to Yes

#19 Updated by Dru Lavigne over 2 years ago

  • Related to Bug #80679: Init/Shutdown scripts should have tooltip and note in guide about sh/zsh added

#20 Updated by Aaron St. John over 2 years ago

  • Needs Doc changed from Yes to No

#21 Updated by Dru Lavigne over 2 years ago

  • Status changed from Passed Testing to Done

Also available in: Atom PDF