CyberPower AN1302 User Manual

Page 1
Application Note – AN1302
Automatic Shutdown NAS in PowerPanel
Rev. 1
2013/10/07
PowerPanel® Business Edition
Users Manual
2013/07/26
Page 2
Shutdown NAS in PowerPanel
Content
Introduction ......................................................................................................................................................................... 2
Set-up.................................................................................................................................................................................. 2
Configuration on Windows .................................................................................................................................................. 2
Download SSH client tool .......................................................................................................................................... 2
Edit External Command of PowerPanel Personal Edition .......................................................................................... 2
Configure Proper Delay Time to Turn Off UPS .......................................................................................................... 3
Configuration on Mac OS X ................................................................................................................................................. 3
Generate an SSH Key ............................................................................................................................................... 3
Edit External Command of PowerPanel for Mac ........................................................................................................ 5
Configure Shutdown Options of Energy Saver .......................................................................................................... 6
Configure Proper Delay Time to Turn Off UPS .......................................................................................................... 6
Configuration on Linux ........................................................................................................................................................ 6
Generate an SSH Key ............................................................................................................................................... 6
Edit External Command of PowerPanel for Linux ...................................................................................................... 7
Configure Proper Delay Time to Turn Off UPS .......................................................................................................... 8
Suggestion .......................................................................................................................................................................... 8
1
Page 3
Shutdown NAS in PowerPanel
echo n | C:\plink.exe –ssh –pw AdminPassword AdminAccount@IpAddress poweroff
Introduction
If you want to properly shut down both the computer and the NAS that are being supplied power by a UPS, this manual will guide through the necessary steps. This will allow the NAS to shut down via the SSH service and the computer to shut down gracefully.
If you are only connecting a NAS to the UPS, you do not need this manual. Simply connect USB cable from the UPS to the NAS and refer to users manual for the NAS about power management instructions.
Set-up
1. Enable the SSH service on the NAS to allow remote SSH login.
QNAP NAS Example:
Log in to the QTS web service and enable Allow SSH connection from Control Panel > Network Services > Telnet/SSH.
Synology NAS Example:
Log in of the DSM web service and check Enable SSH Service from Control Panel > Terminal.
(Refers to your NAS user’s manual for more details about SSH service.)
2. Make sure that the PowerPanel Software has been installed on your computer:
PowerPanel Person Edition is used on Windows. PowerPanel for Mac is used on Mac OS X. PowerPanel for Linux is used on Linux.
3. Plug in your NAS and computer to the UPS outlets labeled BATTERY/SURGE or CRITICAL LOAD.
4. Connect the USB or serial cable between the UPS and the computer to allow PowerPanel to communicate with the UPS.
5. Ensure that there is an active network connection between your computer and NAS.
Configuration on Windows
Download SSH client tool
In order to remote control the NAS equipment via SSH service automatically, use plink.exe as the SSH client tool. Visit http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html, click the download for plink.exe from the list and save it to your desired directory.
Edit External Command of PowerPanel Personal Edition
1. Go to PowerPanel Personal Edition installation directory, such as C:\Program Files(x86)\CyberPower PowerPanel Personal Edition is the default directory.
2. Ensure that you are on an administrative permission.
3. Edit default.cmd as shown below to allow the NAS to shutdown. Note that on older versions of Windows systems such as Win98 or ME, the filename may be default.bat.
2
Page 4
Shutdown NAS in PowerPanel
<shutdown> <hibernate> <off> <delay>600</delay> </off> </hibernate> <shutdown> <off> <delay>600</delay> </off> </shutdown> </shutdown>
AdminAccount and AdminPassword indicate the administrator account and password for NAS.
IpAddress is IP address or domain name of NAS.
When a power event occurs, the external command execution will be initiated prior to the computer shutdown. Refer to the Suggestions chapter for more details.
Configure Proper Delay Time to Turn Off UPS
When a shutdown procedure is initiated, UPS will delay the shutdown of its own outlets. This delay must be long enough to allow for the computer shutdown of both the NAS and the computer. The default setting is 120 seconds (2 minutes). This setting will need to be changed (as shown below) if your NAS and computer take longer than 2 minutes to shut down.
1. Open Notepad application from Start > All Programs > Accessories.
2. Copy and paste the following properties into Notepad.
3. Change the delay time (in seconds) to the needed time for your system to shutdown.
4. Click File > Save As to popup Save As Window.
5. Change location to the PowerPanel installation directory from Save in Drop-down list.
6. Enter shutdown.xml at File name filed and change Save as type to All Files (*.*).
7. Click Save.
8. Restart the PowerPanel Personal Edition service from your services panel or reboot the computer to apply the change.
Configuration on Mac OS X
Generate an SSH Key
In order to control the NAS from a remote SSH session, you must set up the SSH client with a SSH key which will allow the PowerPanel software to execute the shell script on the NAS and shut it down.
This SSH key is generated on a root account for PowerPanel daemon to execute a shell script. Generate a private and a public key by following the steps below:
1. Use root account in Mac OS X a. Choose System Preferences item from the Apple menu. b. Choose Users & Groups from the View menu
3
Page 5
Shutdown NAS in PowerPanel
su root
Password:
ssh-keygen –t rsa
Generating public/private rsa key pair. Enter file in which to save the key (/var/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase): Enter same passphrase again:
Your identification has been saved in /var/root/.ssh/id_rsa. Your public key has been saved in /var/root/.ssh/id_rsa.pub. The key fingerprint is: b1:99:1e:25:a5:f9:c9:86:15:5e:5a:4b:53:4f:a8:c9 root@mac-name.local The key's randomart image is:
+--[ RSA 2048]----+ | | | . . | | E . | | . . o . | | o . . S . . | | + + o . + | |. + o = o + . |
c. Click the lock icon and authenticate as an administrator account. d. Click Login Options. e. Click the Join... button at the lower-right corner. f. Click the Open Directory Utility... button. g. Click the lock icon in the Directory Utility window. h. Enter an administrator account and password, and then click OK. i. Choose Enable Root User from the Edit menu. j. Enter the new root password in both the Password and Verify fields, and then click OK.
(Visit http://support.apple.com/kb/ht1528 for more details in other MAC OS X version.)
2. Launch the Terminal from the Applications > Utilities.
3. Setup SSH client to remote control NAS without assigning password.
a. Switch to the root account.
This requires the root password to complete the authentication.
b. Generate a new RSA key pair.
A prompt will ask you to provide a location to save the keys and a passphrase. The prompt message is shown below: (Press Enter if you want to change nothing.)
And then the ssh-keygen command will also ask you to provide the passpharase. Press ENTER to
accept the default (no passphrase).
After you confirm the passphrase, a key pair will be generated.
4
Page 6
Shutdown NAS in PowerPanel
| o...o * o | |. oo.o . | +------------------------+
scp ~/.ssh/id_rsa.pub AdminAccount@IpAddress:~/.ssh/mac_keys
The authenticity of host '192.168.20.10 (192.168.20.10)' can't be established. RSA key fingerprint is b1:99:1e:25:a5:f9:c9:86:15:5e:5a:4b:53:4f:a8:c9. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added '192.168.20.10' (RSA) to the list of known hosts. root@192.168.20.10's password:
ssh AdminAccount@IpAddress
cat ~/.ssh/mac_keys >> ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys
Exit
ssh AdminAccount@IpAddress poweroff
c. Copy Macs public key file (id_rsa.pub) to SSH server of NAS for new mac_keys.
AdminAccount is the administrator account of NAS. IpAddress is the IP address or domain name of
NAS.
This command requires entering yes and the NAS administrator’s password to continue connection. The message shows as below example:
d. Login to NAS via SSH client command
AdminAccount is the administrator account of NAS. IpAddress is the IP address or domain name of
NAS.
e. Append Macs public key (mac_keys) to NASs authorized_keys.
f. Change the access permission of the public key.
g. Logout NAS.
4. Refer to the step 1 to disable root account in Mac OS X If you want to keep disabled.
Edit External Command of PowerPanel for Mac
Edit the script of PowerPanel application allowing to shutdown NAS from the below steps.
1. Open PowerPanel application from Applications.
2. Make sure that you have installed the Daemon from the Configure toolbar > Daemon tab.
3. Click the lock icon and authenticate as an administrator account.
4. Click the Edit script button from the Configure toolbar > Shutdown tab.
5. Append the below command to allow to shutdown NAS.
5
Page 7
Shutdown NAS in PowerPanel
AdminAccount is the administrator account of NAS. IpAddress is the IP address or domain name of NAS.
6. Click OK to save script.
When a power event occurs, the external command execution will be initiated prior to the computer being shut down. Refer to the Suggestions chapter for more details.
Configure Shutdown Options of Energy Saver
Use the following steps to configure shutdown options for power events in the Energy Saver panel.
1. Choose System Preferences.... from the Apple menu.
2. Choose Energy Saver from the View menu.
3. Click the lock icon and authenticate as an administrator account.
4. Click UPS tab view.
5. Click the Shutdown Options... button.
6. Select the target shutdown option and change the time or percentage. (E. G. Enable the Shut down the
computer after using the UPS battery for: option and set the proper time.)
7. Click Done button to complete.
Configure Proper Delay Time to Turn Off UPS
When a shutdown procedure is initiated, the UPS will delay the shutdown of its own outlets. This delay must be long enough to allow for the computer shutdown of both the NAS and the computer. The default setting is 180 seconds (3 minutes). This setting will need to be changed if your NAS and computer take longer than 3 minutes to shut down.
1. Open PowerPanel application.
2. Make sure that you have installed Daemon from the Configure toolbar > Daemon tab.
3. Click the lock icon and authenticate as an administrator account.
4. Make sure that the Turn off UPS when computer shuts down option is checked.
5. Assign a proper delay time from the Delay to turn off UPS when computer shuts down Drop-down list.
Configuration on Linux
Generate an SSH Key
In order to control the NAS from a remote SSH session, you must set up the SSH client with an SSH key which will allow the PowerPanel software to execute the shell script on the NAS and shut it down.
This SSH key is generated on an root user account. Generate a private and a public key by following the steps below:
1. Switch to root account.
6
Page 8
Shutdown NAS in PowerPanel
su root
Password:
ssh-keygen –t rsa
Generating public/private rsa key pair. Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase): Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa. Your public key has been saved in /root/.ssh/id_rsa.pub.
ssh-copy-id –i /root/.ssh/id_ras.pub AdminAccount@IpAddress
The authenticity of host '192.168.20.10 (192.168.20.10)' can't be established. RSA key fingerprint is b1:99:1e:25:a5:f9:c9:86:15:5e:5a:4b:53:4f:a8:c9. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added '192.168.20.10' (RSA) to the list of known hosts. root@192.168.20.10's password:
ssh AdminAccount@IpAddress poweroff
A prompt ask you to provide the root password to complete the authentication.
2. Generate a new RSA key pair.
This command will ask you to provide a location to save the keys and a passphrase. (Press Enter if you change nothing.)
The prompt message shows as below example:
And then ssh-keygen command also asks you to provide a passphrase. Press ENTER to accept the default (no passphrase).
After you confirm the passphrase, the key pair will be generated.
3. Copy public key to SSH server of NAS.
AdminAccount is the administrator account of NAS. IpAddress is the IP address of NAS. This command
requires entering yes and the NAS administrator password to continue connection.
The message shows as below example:
Edit External Command of PowerPanel for Linux
Use vi command to edit /etc/pwrstatd-powerfail.sh and /etc/pwrstatd-lowbatt.sh. Append below shell command to allow the shutdown of the NAS.
AdminAccount is the administrator account of NAS. IpAddress is the IP address or domain name of NAS.
7
Page 9
Shutdown NAS in PowerPanel
/etc/init.d/pwrstatd stop
/etc/init.d/pwrstatd start
When a power event occurs, the external command execution will be initiated prior to the computer being shut down. Refer to the Suggestions chapter for more details.
Configure Proper Delay Time to Turn Off UPS
When a shutdown procedure is initiated, the UPS will delay the shutdown of its own outlets. This delay must be long enough to allow for the computer shutdown of both the NAS and the computer. The default setting is 600 seconds (10 minutes). This setting will need to be changed if your NAS and computer take longer than 10 minutes to shut down.
1. Stop daemon of PowerPanel.
2. Use vi to open /etc/pwrstatd.conf.
3. Search for shutdown-sustain = 600 and modify it for the necessary time (in seconds) your NAS and computer to shut down.
4. Save the file and quit vi.
5. Start the PowerPanel daemon.
Suggestion
1. A NAS remote login requires admin or root account. Note: The Synology NAS equipment requires root password whose default password is same as administrator password.
2. Because your IP address which is dynamically obtained may change, you must use the domain name to replace with the IP address. The NAS shutdown may not work due to the IP address changed. Recommends using DDNS service to resolve the dynamic IP address issue. Refer to NAS users manual for advanced details about DDNS service.
3. PowerPanel software had tested on Synology and QNAP NAS.
8
Loading...