x213212
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
      • Invitee
    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Versions and GitHub Sync Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
Invitee
Publish Note

Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

Your note will be visible on your profile and discoverable by anyone.
Your note is now live.
This note is visible on your profile and discoverable online.
Everyone on the web can find and read all notes of this public team.
See published notes
Unpublish note
Please check the box to agree to the Community Guidelines.
View profile
Engagement control
Commenting
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
  • Everyone
Suggest edit
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
Emoji Reply
Enable
Import from Dropbox Google Drive Gist Clipboard
   owned this note    owned this note      
Published Linked with GitHub
Subscribed
  • Any changes
    Be notified of any changes
  • Mention me
    Be notified of mention me
  • Unsubscribe
Subscribe
ds218j https://global.download.synology.com/download/Document/HIG/DiskStation/18-year/DS218j/Syno_HIG_DS218j_cht.pdf # 下載 ![](https://i.imgur.com/34UiLfd.png) # 安裝 ![](https://i.imgur.com/wFiUpA2.png) ![](https://i.imgur.com/OjZNjdy.png) ![](https://i.imgur.com/q2gjVZt.png) ![](https://i.imgur.com/RdD7j7g.png) ![](https://i.imgur.com/KL1qvGa.png) ![](https://i.imgur.com/3mZQYEl.jpg) ![](https://i.imgur.com/ccMS8v6.png) ![](https://i.imgur.com/FCU88by.png) ![](https://i.imgur.com/4gc0mLN.jpg) ![](https://i.imgur.com/gZQmVGx.jpg) ![](https://i.imgur.com/xKW9GS3.png) ![](https://i.imgur.com/QJMFcSo.jpg) ![](https://i.imgur.com/7OGDgiq.jpg) ![](https://i.imgur.com/HzKazR0.jpg) ![](https://i.imgur.com/3R3yyKX.jpg) ![](https://i.imgur.com/rgDgO2f.jpg) ![](https://i.imgur.com/Ihq00Dd.jpg) ![](https://i.imgur.com/eEbNdd7.jpg) # apc不斷電系統 ## 安裝 nut ups tool >x213212@x213212-desktop:~$ sudo apt-get install nut-server nut-client nut-monitor s-nail ## 基礎設定 x213212@x213212-desktop:/etc/nut$ lsusb Bus 002 Device 002: ID 0bda:0411 Realtek Semiconductor Corp. Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub Bus 001 Device 003: ID 8087:0a2b Intel Corp. Bus 001 Device 006: ID 3938:1034 Bus 001 Device 005: ID 04d9:0161 Holtek Semiconductor, Inc. Bus 001 Device 004: ID 0eef:0005 D-WAV Scientific Co., Ltd :::info :bulb: *一定要設置 你的 usb "bus" 和 "device" 如上* 確定抓到 American Power Conversion Uninterruptible Power ::: >Bus 001 Device 007: ID 051d:0002 American Power Conversion Uninterruptible Power Bus 001 Device 002: ID 0bda:5411 Realtek Semiconductor Corp. Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub once try these things, You can use lsusb to find out the bus and device number Then change permission to the device > chmod 0666 /dev/bus/usb/[bus number]/[device number] as for details go with rouble starting Network UPS Tools with a Eaton 3S UPS share improve this answer 設定完 # 系統配置 x213212@x213212-desktop:/etc/nut$ sudo upsc mge ![](https://i.imgur.com/1WXghR8.png) 就可以順利看到我們的ups 內容囉~ ![](https://i.imgur.com/dsaLyV9.png) ![](https://i.imgur.com/Q4sY6NU.png) >shutdown -h now ![](https://i.imgur.com/pd2zleQ.png) https://www.vediotalk.com/?p=2211 跟著設權限 ![](https://i.imgur.com/Nz9cWwZ.png) 有囉~ ![](https://i.imgur.com/fm7U2iX.png) 安裝 sshpass ![](https://i.imgur.com/WtpRTi9.png) 開始寫小東西 >apt-get install sshpass >sshpass -p rootx root@192.168.0.105 那個我們只要跟著下 >sshpass -p rootx ssh root@192.168.0.105 'shutdown -h now' 我們的nas就關機囉 那我們在 我們上次的ubuntu 來寫script吧~ ![](https://i.imgur.com/iWepgwW.png) 簡單script 設置什麼好亂 乾脆自己來xd ```bash while : do clear sleep 1 TAROUTPUT=$( upsc mge | grep -E "ups.status") TAROUTPUT2=$( upsc mge | grep -E "battery") substr=$( echo ${TAROUTPUT/ups.status: /""}) # echo $substr # if [ $substr == "OL" or $substr == "OL CHRG"]; then # echo "good" # else # echo "bad" #fi case "$substr" in "OL CHRG") echo "充電中" ;; "OL") echo "已經完全充滿" ;; *) echo "已經拔除電源,通知系統關機。" sshpass -p rootx ssh root@192.168.0.105 'shutdown -h now' break; esac # echo $substr # echo $TAROUTPUT # echo "\n" # echo $TAROUTPUT2 done ``` ![](https://i.imgur.com/B45QIZS.jpg) ![](https://i.imgur.com/zyjPqqX.jpg) ![](https://i.imgur.com/149vXwB.jpg) ![](https://i.imgur.com/XhrOASB.jpg) 背景執行 >nohup bash ups.sh &> /dev/null & jobs 可以看到運行中的 任務 這樣 斷電的時候我的 nas 就可以自動關機囉~ # 自幹系列 2 ![](https://i.imgur.com/uDLZ8w5.png) 沒有像 ![](https://i.imgur.com/JKrrn0E.png) 這樣的畫面呢 來寫一個陽春的監測畫面好了node.js~ ```javascript= let express = require('express'); let app = express(); let router = express.Router(); let exec = require('child_process').exec; let port = 9000; //app.use(express.static(__dirname + '/public')); //app.use('/img', express.static(__dirname + '/public/img')); let header = '<!DOCTYPE html><html><head><title>ctrl PHP</title>' + '<meta http-equiv="Content-Type" content="text/html; charset=utf-8">' + '<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">' + '<meta http-equiv="refresh" content="1" >' + '</head><body><pre>'; let footer = "</pre></body></html>"; router.get('/', function (req, res, next) { //預設頁面 console.log('index'); res.sendfile('index.html', {root: __dirname + "/public"}); }); router.get('/ls', function (req, res, next) { //執行 ls -al 指令 exec('sudo upsc mge | grep -E "ups.status|battery"', function (err, stdout, stderr) { console.log('ls'); res.send(header + stdout + footer + stderr + err ); }); }); app.use('/', router); app.listen(port); app.listen(3000, function () { console.log('Example app listening on port 3000!'); }); ``` ![](https://i.imgur.com/ih7Xh5y.png) 運行一下 ![](https://i.imgur.com/uDLZ8w5.png) ![](https://i.imgur.com/wVp5NB2.png) ![](https://i.imgur.com/Uj9HpVy.png) ![](https://i.imgur.com/MHetQK2.jpg) ![](https://i.imgur.com/DF4M9Oj.png) ![](https://i.imgur.com/2qCBGkm.png) ![](https://i.imgur.com/9mBDbQD.png) ![](https://i.imgur.com/zm918tx.png) ![](https://i.imgur.com/DZ5FfyU.png) ![](https://i.imgur.com/MzhVYwf.png) ![](https://i.imgur.com/zsGK42t.png) ![](https://i.imgur.com/jl3jUxR.png) ![](https://i.imgur.com/iVttCjA.png)

Import from clipboard

Paste your markdown or webpage here...

Advanced permission required

Your current role can only read. Ask the system administrator to acquire write and comment permission.

This team is disabled

Sorry, this team is disabled. You can't edit this note.

This note is locked

Sorry, only owner can edit this note.

Reach the limit

Sorry, you've reached the max length this note can be.
Please reduce the content or divide it to more notes, thank you!

Import from Gist

Import from Snippet

or

Export to Snippet

Are you sure?

Do you really want to delete this note?
All users will lose their connection.

Create a note from template

Create a note from template

Oops...
This template has been removed or transferred.
Upgrade
All
  • All
  • Team
No template.

Create a template

Upgrade

Delete template

Do you really want to delete this template?
Turn this template into a regular note and keep its content, versions, and comments.

This page need refresh

You have an incompatible client version.
Refresh to update.
New version available!
See releases notes here
Refresh to enjoy new features.
Your user state has changed.
Refresh to load new user state.

Sign in

Forgot password

or

By clicking below, you agree to our terms of service.

Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
Wallet ( )
Connect another wallet

New to HackMD? Sign up

Help

  • English
  • 中文
  • Français
  • Deutsch
  • 日本語
  • Español
  • Català
  • Ελληνικά
  • Português
  • italiano
  • Türkçe
  • Русский
  • Nederlands
  • hrvatski jezik
  • język polski
  • Українська
  • हिन्दी
  • svenska
  • Esperanto
  • dansk

Documents

Help & Tutorial

How to use Book mode

Slide Example

API Docs

Edit in VSCode

Install browser extension

Contacts

Feedback

Discord

Send us email

Resources

Releases

Pricing

Blog

Policy

Terms

Privacy

Cheatsheet

Syntax Example Reference
# Header Header 基本排版
- Unordered List
  • Unordered List
1. Ordered List
  1. Ordered List
- [ ] Todo List
  • Todo List
> Blockquote
Blockquote
**Bold font** Bold font
*Italics font* Italics font
~~Strikethrough~~ Strikethrough
19^th^ 19th
H~2~O H2O
++Inserted text++ Inserted text
==Marked text== Marked text
[link text](https:// "title") Link
![image alt](https:// "title") Image
`Code` Code 在筆記中貼入程式碼
```javascript
var i = 0;
```
var i = 0;
:smile: :smile: Emoji list
{%youtube youtube_id %} Externals
$L^aT_eX$ LaTeX
:::info
This is a alert area.
:::

This is a alert area.

Versions and GitHub Sync
Get Full History Access

  • Edit version name
  • Delete

revision author avatar     named on  

More Less

Note content is identical to the latest version.
Compare
    Choose a version
    No search result
    Version not found
Sign in to link this note to GitHub
Learn more
This note is not linked with GitHub
 

Feedback

Submission failed, please try again

Thanks for your support.

On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

Please give us some advice and help us improve HackMD.

 

Thanks for your feedback

Remove version name

Do you want to remove this version name and description?

Transfer ownership

Transfer to
    Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

      Link with GitHub

      Please authorize HackMD on GitHub
      • Please sign in to GitHub and install the HackMD app on your GitHub repo.
      • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
      Learn more  Sign in to GitHub

      Push the note to GitHub Push to GitHub Pull a file from GitHub

        Authorize again
       

      Choose which file to push to

      Select repo
      Refresh Authorize more repos
      Select branch
      Select file
      Select branch
      Choose version(s) to push
      • Save a new version and push
      • Choose from existing versions
      Include title and tags
      Available push count

      Pull from GitHub

       
      File from GitHub
      File from HackMD

      GitHub Link Settings

      File linked

      Linked by
      File path
      Last synced branch
      Available push count

      Danger Zone

      Unlink
      You will no longer receive notification when GitHub file changes after unlink.

      Syncing

      Push failed

      Push successfully