\documentclass[letterpaper]{article}
\nonstopmode
\bkai
\usepackage{linuxdoc-sgml}
\usepackage{qwertz}
\usepackage{url}
\usepackage[latin1]{inputenc}
\usepackage{t1enc}
\usepackage[english]{babel}
\usepackage{epsfig}
\usepackage{null}
\def\addbibtoc{
\addcontentsline{toc}{section}{\numberline{\mbox{}}\relax\bibname}
}%end-preamble
\setcounter{page}{1}
\title{¤¤¤å UPS Howto}
\author{Harvey J. Stein, \onlynameurl{abel@netvision.net.il}, Berger Financial Research, Ltd.}
\date{v2.02, 31 March 1997}
\abstract{¥»¤å¯àÀ°§U±z±N Linux ¨t²Î³s±µ¨ì¤£Â_¹q¨t²Î (uninterruptable power supply, UPS)...
¦pªG©¯¹Bªº¸Ü ....
ª©ÅvÁn©ú:
Copyright (c) 1994, 1995, 1996, 1997 by Harvey J. Stein.  You may use
this document as you see fit, as long as it remains intact.  In
particular, this notice (along with the contributions below) must
remain untouched.}


\begin{document}
\maketitle
\tableofcontents

\section{Â²¤¶}



¥» HOWTO ¤å¥ó¥]§t¤F¦p¦ó³s±µ UPS ¨ì°õ¦æ Linux ªº¹q¸£¤W¡C
¨ä·Qªk¬O¥H¾A·íªº¤è¦¡±N¤GªÌ¬Û³s±µ¡A¨Ï±o Linux 
¥i¥H¦b¹q·½Â_¹q¥H¤Î UPS ªº¹q¦À¯Ó¥ú«e¦w¥þ¦aÃö¾÷¡C

¨ä¤¤ÁÙ¥]¬A¤F¤@¨Ç¥iÀ°§U±z«Ø¥ß¤W­z³s½uªº³nÅé¡A¥H¤Î¸Ô­z¸Ó³s½uªº¹B§@¤è¦¡¡C
°²¦p±z¯à§ä¨ì¤@­Ó¤w³]©w¦n¥i¥H¨Ï¥Î±zªº UPS ªº³nÅé¡A
«h«áªÌªº»¡©ú¹ï±z¨Ó»¡³q±`¬O¤£»Ý­nªº¡C§_«hªº¸Ü¡A±z¥²¶·¥J²Ó¦a¾\Åª¥¦¡C

¦b¬Û·íªºµ{«×¤W¥»¤å¥ó¤w¤ñ°_§Ú¦b¤T¦~«e©Ò¼¶¼gªº­ì¤å¦h¥X¤F«Ü¦h¤º®e¡C
©Ò¦³ªº°ò¥»¸ê®Æ³£¥i¥H¦b {\ttfamily SysVinit} ¤¤ªº {\ttfamily powerd} man page ùØ§ä¨ì¡C
¾¨ºÞ¦b¤T¦~«e¦³¤H¥i¯àµLªk¦b¤@¯ëªº Linux ®M¥ó¤¤§ä¨ì³o½g man page ¡A
¦ý§Ú¤£¬Û«H¤µ«áÁÙ·|¦Aµo¥Í³o¼Ëªº±¡ªp¡C

°£¦¹¤§¥~¡A·í§Ú²Ä¤@¦¸¼¶¼g³o½g Howto ¡A°£¤F {\ttfamily powerd.c}
¥H¥~¨Ã¨S¦³¨ä¥Lªº³nÅé¥i¥H°µ¬° Linux/UPS ¤§¶¡ªº·¾³q»P±±¨î¡C
¦Ó¤µ¤é§Ú­Ì«h¥i¥H¦b \nameurl{http://sunsite.unc.edu:/pub/Linux/system/ups}{Sunsite's UPS directory}
¤U§ä¨ì¤@¤j°ï UPS ±±¨î³nÅé¡C

µM¦Ó¡A¨ü¨ì RedHat §Y±N­«·s¦L»s Dr. Linux ªº¿EÀy¡A§Ú¤]¶}©l­«¼g³o½g UPS Hotwo ¡C
¬°¤°»ò©O? ¶â ....

\begin{itemize}
\item §Ú·Q¡AÃB¥~ªº¤@¯ë©Ê·§Æ[±N¯à¦³§U©ó¤F¸Ñ¦p¦ó±N Linux ¨t²Î³s¤W UPS ¡A
§Y¨Ï¥¦¥u¬O¥t¤@¥÷¤º®e¬Û¦Pªº¤å¥ó¡C
\item ³o½g HOWTO ºâ¬O¦UºØ¯S®í UPS ¸ê®ÆªºÀxÂÃ®w --- 
¦b³o¨à¦³³\¦h©|¥¼³Q¾ã¦X¤J¤@¯ë³nÅé®M¥ó¤¤ªº UPS ¸ê°T¡C
\item ³o½g HOWTO ¥]§t¤F¤@¨Ç¦b¨ä¥L¤å¥ó¤¤§ä¤£¨ìªºÃB¥~¸Ô²Ó¸ê®Æ¡C
\item ¤@¨Ç¥i¥H¦b \nameurl{http://sunsite.unc.edu:/pub/Linux/system/ups}{Sunsite's UPS directory} 
§ä±o¨ìªº UPS ³nÅé¦ü¥G»¡©ú¤å¥ó³£¤Ö±o¥i¼¦¡C
±z¤]³\»Ý­n¥ý¾\ðé¥»¤å¥H¤F¸Ñ¦p¦ó¨Ï¥Î¥L­Ì¡C
\item ²{¦b³o¥ó¨Æ¦ü¥G¤w¦³¤F¦Û¤vªº¥Í©R¤F¡C·í¤@½g HOWTO 
¤å¥ó¦]¦Ó½Ï¥Í®É¨Æ¹ê´N§ó¥[©úÅã¤F¡C¥t¤@­Ó¤ñ¸û¤£©úÅãªº¨Æ¹ê¬O·í¥¦¥²¶·¤W§ÉºÎÄ±®É¡C

(Ä¶µù: ³o¤@¥y¯º¸Ü§Ú¬Ý¤£À´°Õ! ­ü! Â½±o¦nÄê ....)
\end{itemize}





\subsection{¦³°^Ämªº¤H­Ì}



§Ú¥Ã»·³£·|·P¿E¨º¨Ç´¿¸gµ¹§ÚÀ°§U¡Bµ¹§Ú«ØÄ³¡B¥H¤Îµ¹§Ú¯S®íªº UPS ¸ê®Æªº¤H­Ì¡C
¨ä¤¤¥]¬A¤F:

\begin{itemize}
\item Hennus Bergman
(\onlynameurl{hennus@sky.owl.nl})
\item Charli
(\onlynameurl{mefistos@impsat1.com.ar})
\item Ciro Cattuto
(\onlynameurl{Ciro Cattuto})
\item Nick Christenson
(\onlynameurl{npc@minotaur.jpl.nasa.gov})
\item Lam Dang
(\onlynameurl{angit@netcom.com})
\item Markus Eiden
(\onlynameurl{Markus@eiden.de})
\item Dan Fandrich
(\onlynameurl{dan@fch.wimsey.bc.ca})
\item Ben Galliart
(\onlynameurl{bgallia@orion.it.luc.edu})
\item Danny ter Haar
(\onlynameurl{dth@cistron.nl})
\item Christian G. Holtje
(\onlynameurl{docwhat@uiuc.edu})
\item Raymond A. Ingles
(\onlynameurl{inglesra@frc.com})
\item Peter Kammer
(\onlynameurl{pkammer@ics.uci.edu})
\item Marek Michalkiewicz
(\onlynameurl{ind43@sun1000.ci.pwr.wroc.pl})
\item Jim Ockers
(\onlynameurl{ockers@umr.edu})
 
\item Evgeny Stambulchik
(\onlynameurl{fnevgeny@plasma-gate.weizmann.ac.il})
\item Clive A. Stubbings
(\onlynameurl{cas@vjet.demon.co.uk})
\item Miquel van Smoorenburg
(\onlynameurl{miquels@cistron.nl})
\item Slavik Terletsky
(\onlynameurl{ts@polynet.lviv.ua})
\item Tom Webster
(\onlynameurl{webster@kaiwan.com})
\end{itemize}


½Ðª`·N¤U¤èªº email ¦a§}¬O¦Û¹q¤l«H¥ó¤¤¸`¿ý¤U¨Óªº¡A¥¦­Ì¤]³\·|¹L´Á¡C
¦Ó¤W¤èªº email ¦a§}¥i¯à¤]·|¹L´Á¡A¦ý¦³¨Ç¬O¤ñ°_¤U¤èÁÙ­n·sªº¡C

°£¦¹¤§¥~¡A¦pªG¦]§Úªº²¨©¿¦Ó¦b¤Wªí¤¤º|±¼¥ô¦ó¤@¦ì¦³°^ÄmªÌªº¸Ü¡A§Ú¯uªº«Ü©êºp¡C
½Ð±z email µ¹§Ú¡A§Ú·|±N±zªº¦W¦r¥[¤W¥h¡C






\subsection{½Ð¯S§Oª`·N}

§Ú¯uªºµLªk«OÃÒ³o¨ÇªFªF¹ï±z·|¦³®Ä¡C³sµ² UPS ¨ì¹q¸£¤W¬O¤@¥ó¬Û·í¦³§Þ¥©ªº¤u§@¡C
¨ä¤¤¤§¤@©Î¤GªÌ³£¦³¥i¯à·|¿N±¼¡BÃz¬µ¡BµÛ¤õ¡B©ÎªÌ¬O¤Þµo²Ä¤T¦¸¥@¬É¤j¾Ô¡C
°£¦¹¤§¥~¡A§Ú¥u¦³¹ï Advice 1200 A UPS¡A¥H¤Î 5kva Best Ferrups ¦³ª½±µªº¸gÅç¡A
¦Ó¥B§Ú¤]¤£»Ý­n¦Û¤v°µ¤@±ø°T¸¹½u¡C©Ò¥H¡A½Ðª`·N! ¾¨¥i¯à¦a¦¬¶°±zªº UPS ªº©Ò¦³¸ê°T¡C
½Ð¥ý¦Ò¼{²M·¡¡A¤£­nÀH«K¬Û«H¥ô¦ó±z¦b¥»¤å¤¤©Î¨ä¥L¦a¤è©ÒÅª¨ìªº¤º®e¡C

¥t¤@¤è­±¡A§Ú¥¿ºÉ¥i¯à¦a¦¬¶°©Ò¦³¨Ï§Úªº UPS ¥i¥H¤u§@ªº¤èªk¡A
¨ä¤¤¦³«Ü¦h¤£¬O¨Ó¦Û»s³y°Óªº¸ê°T¡A©Ò©¯¤]¨S¦³¿N±¼¥ô¦óªF¦è¡A©Ò¥H³o¨Ç³£¬O¥i¯àªº¡C






\subsection{¨ä¥Lªº¤å¥ó}

¥»¤å¨Ã¨S¦³¥]§t©Ò¦³ UPS ªº¤@¯ë¯S©Ê»P¯à¤O¡C¦p±z»Ý­n³oÃþ«¬ªº¸ê°T¡A§A¥i¥H¬Ý¬Ý
\nameurl{ftp://navigator.jpl.nasa.gov/pub/doc/faq/UPS.faq}{The UPS FAQ}¡C
³o½g¤å¥ó¦P®É¤]¥i¥H¦b \onlynameurl{ftp://rtfm.mit.edu/pub/usenet-by-hierarchy/comp/answers/UPS-faq}
¤¤§ä¨ì¡C¥¦¬O¥Ñ Nick Christenson (\onlynameurl{npc@minotaur.jpl.nasa.gov})
©ÒºûÅ@ªº¡A¦ý¬Ý°_¨Ó¦n¹³¦Û±q 1995 ¦~¥H«á´N¨S¦³¦A­«¼g¤F¡C¦pªG±z­n email µ¹¥L¡A
¥L§Æ±æ±z¥i¥H¦b«H¥óªº Subject ¨º¤@¦æ©ñ¤J {\ttfamily UPS} ©Î {\ttfamily UPS FAQ} 
©Î¨ä¥L¬ÛÃöªºµü¥y¡C

¦³³\³\¦h¦hªº UPS »s³y°Ó¦bºô¸ô¤¤µÞªÞ¡C
¨ä¤¤¦³¨Ç½T¹ê¦b¥L­Ìªººô­¶¤¤´£¨Ñ¤F¦³¥Îªº¸ê°T¡C±z¥i¥H¦b
\nameurl{http://www.upssystems.uk.com/upsdir.html}{The UPS Directory} ¤¤§ä¨ì³o¨Ç UPS 
»s³y°Óªººô­¶Â²ªí¡C¸Óºô¯¸¤]¥]§t¤F
\nameurl{http://www.upssystems.uk.com/upsfaqs.html}{UPS FAQ}
³o½g¤å¥ó¡C






\section{½Ðª`·N¤w¹L®Éªº¸ê°T}

§Ú­è­èµo²{©³¤U¦³¤@¨Ç¸ê®Æ¤w¸g¹L®É¤F¡C¨ä¤¤¨Ó¦Û
\nameurl{http://sunsite.unc.edu/pub/Linux/system/daemons/init/sysvinit-2.64.tar.gz}{the latest sysvinit package}
ªº {\ttfamily init} daemon ¤ñ°_§Ú©Ò¯à´y­zªºÁÙ­nÂ²­®¡C
¾¨ºÞ¬Ý°_¨Ó¥Ø«eªºª©¥»»P¸Óµ{¦¡§¹¦¨®Éªºª©¥»¬Û®e¡A¦ý·í¤¤¤´µM¦³¤@¨Ç¹ï UPS
{\bfseries ¬Û·í­«­n} ªº¤ä´©¨S¦³¤å¥ó»¡©ú¡C

©³¤U©ÒÂ²­zªº±±¨î¾÷¨î¥u¯àÅý {\ttfamily powerd} °eµ¹ {\ttfamily init} {\ttfamily powerfail} ©Î
{\ttfamily powerok} ³o¨â­Ó°T®§¤§¤@¦Ó¤w¡C{\ttfamily init} ±µ¨ì {\ttfamily powerfail} 
°T®§®É°õ¦æ¤@­Ó©R¥O¡A¦Ó·í¥¦±µ¨ì {\ttfamily powerok} ®É«h°õ¦æ¥t¤@­Ó©R¥O¡C
³o±N¾É¦Ü {\ttfamily powerd} ¦b³B²z§C¹q¤O°T¸¹¤Î¨ä¥L¯S®íª¬ªp®É²£¥ÍÅÞ¿è¤Wªº½ÆÂø©Ê¡C

¸û·sª©¥»ªº {\ttfamily init} (¹³¬O 2.58 ª©) ´N¤ñ¸ûºë¨}¤F¡C
¥¦¥i¥H¦b±µ¨ì°T¸¹®É¿ï¾Ü {\ttfamily ¤T­Ó} script ¤¤¤§¤@¨Ó°õ¦æ¡C¦p¦¹¤@¨Ó¡A {\ttfamily init}
¥i¥H¦b±µ¨ì¹q·½Â_¹q°T¸¹®É°õ¦æ {\ttfamily powerfail} script ¡A¥i¥H°õ¦æ¤@­Ó
{\ttfamily powerfailnow} script °µ¥ß§YªºÃö¾÷ ¡A¥H¤Î¤@­Ó {\ttfamily powerok} script
¨Ó°±¤î¥ô¦ó¥¿¦b¶i¦æªºÃö¾÷°Ê§@¡C³o¼Ë¤ñ°_­n§Ú­Ì¦Û¦æ³B²z³o¨Ç¾÷¨î­nÂ²³æ¦h¤F¡C

¾¨ºÞ³oùØ¤j³¡¤Àªº°Q½×¤´°²³]¨Ï¥ÎÂÂªº {\ttfamily init} ³q°T¤è¦¡¡A
§Ú¤w¥[¤J¤F¨â­Ó·sªº³¹¸`¨Ó´y­z·sªº³s½u¤èªk¡C³o¨â­Ó³¹¸`¬O \ref{ciro} {(Trust Energy Protector 400/650)} ¤Î \ref{apc700} {(APC Smart-UPS 700)}¡C¨ä¤¤«eªÌ¯S§O¸Ô²Ó¡C¤GªÌ³£¥]§t¤F¤@­Ó {\ttfamily powerd.c} ÀÉ¡A
¥¦¥i¥H¦b¦¬¨ì§C¹q¤O°T¸¹®É°e°T¸¹µ¹ {\ttfamily init} ¥H¶i¦æºò«æÃö¾÷¡A
´N¹³¬O {\ttfamily /etc/inittab} ÀÉ¤¤¨º´X¦æ©Ò¼gªº¤@¼Ë¡C¨ä¾lªº¡A
§Ú©Ò¯à§i¶D±zªº´N¥u¦³½Ð±z¬Ý¬Ý {\ttfamily init} ªº­ì©l½X¤F¡C

´N§Ú©Òª¾ªº¡A¦b¥H¤U©Ò¦Cªº UPS ³nÅé®M¥ó¤¤¦³³\¦h¤]±Ä¥Î¤F·s¦¡ªº³s½u¤è¦¡¡C




\section{Áo©úªº»P³æ½Õªº UPS}

UPS ¤j¦Ü¤À¬°¨âÃþ¡A§Ú¤À§O¥s¥¦­Ì ``Áo©úªº (Smart)''»P ``³æ½Õªº (Dumb)''¡C
¤GªÌ¤§¶¡ªº®t²§¦b©ó§Ú­Ì¯à¦Û UPS Àò±o¦h¤Öªº°T®§¥H¤Î§Ú­Ì¯à°÷¹ï UPS ¤U¹F¦h¤Ö©R¥O¡C



\begin{description}
\item[³æ½Õªº UPS] \mbox{}

\begin{itemize}
\item ÂÇ¥Ñ§Ç¦Cªú (serial port) »P¹q¸£¬Û³s¡C
\item ¨Ï¥Î modem ±±¨î½u»P¹q¸£¬Û³q°T¡C
\item ¥i¥H¦b¹q¤O¬O§_®ø¥¢®Éµ¹¹q¸£°e°T¸¹¡C
\item ¤]³\¥i¥H¦b UPS ªº¹q¤O¬O§_°¾§C®É³qª¾¹q¸£¡C
\item ¹q¸£³q±`¥i¥H°e°T¸¹µ¹ UPS Åý¥¦±N¦Û¤vÃö³¬¡C
\end{itemize}




\item[Áo©úªº UPS] \mbox{}

\begin{itemize}
\item ÂÇ¥Ñ§Ç¦Cªú (serial port) »P¹q¸£¬Û³s¡C
\item ¥H¤@¯ëªº¸ê®Æ¶Ç¿é½u¸g§Ç¦Cªú»P¹q¸£·¾³q¡C
\item ¦h¥b¦³¤@²Õ©R¥O»y¨¥¥i¥HÅý¹q¸£¦Û UPS ¨º±oª¾¦U¦¡¦U¼Ëªº¸ê°T¡A
¥H³]©w¦UºØ¹B§@°Ñ¼Æµ¹ UPS¡A¦P®É¤]¾Þ§@ UPS (¹³¬O±N¥¦Ãö±¼)
\end{itemize}




\end{description}




³q±`Áo©úªº UPS ³£¥i¥H¦b³æ½Õªº¼Ò¦¡¤U¾Þ§@¡C³o¬O«Ü¦³¥Îªº¡A¦]¬°´N§Ú©Òª¾¡A
³Ì±`¨£ªºÁo©ú UPS (¹³¬O APC) »s³y°Ó¥uÄ@·N³zÅS¥L­Ìªº UPS 
³q°T¨ó©wµ¹¨º¨ÇÃ±¸p¤Fµ´¤£¬ªÅS¾÷±K¦P·N®Ñªº¤H­Ì¡C

´N§Ú©Òª¾¡A¥u¦³ BEST ¤½¥q©Ò»s§@ªº UPS ¥i¥H«Ü®e©ö¦a¦b Linux ¤U¹B§@¡C
°£¦¹¤§¥~¡A BEST ¤½¥qÁÙ¦³§¹¾ãªº¤å¥ó»¡©ú¤F¥L­Ìªº UPS ªºÁo©ú¼Ò¦¡ 
(¥H¤Î³æ½Õ¼Ò¦¡)¡C BEST ¤½¥q¤]´£¨Ñ¤F¥i¥H»P¥L­Ìªº UPS ·¾³qªºµ{¦¡ªº­ì©l½X¡C

©Ò¦³¦C¦b \ref{software} {(³nÅé)} ³¹¸`ªº³nÅé¬Ò¥i¦b³æ½Õ¼Ò¦¡¤U»P
UPS ·¾³q¡C³o¨Ç³£¬O±z¯u¥¿»Ý­nªº¡C¦³¨Ç³nÅé«h«ÅºÙ»¡¥i¥H¦bÁo©ú¼Ò¦¡¤U¾Þ§@
ARC UPS ¡A¦ý§Ú¤£ª¾¹D¥L­Ì¬O¦p¦óÀò­ã¦Ó°µ¨ìªº¡C
¤@­Ó§¹¾ãªºµ{¦¡¹B§@·|¸õ¥X¤@­Óµøµ¡¡AùØÀY¥]§t¤F¦³½ìªº«×¶qªí¡A
¥NªíµÛ¦U¦¡¦U¼Ëªº UPS ²Î­p¸ê®Æ¡A¹³¬O­t¸üµ{«×¡B¤º³¡·Å«×¡BÂ_¹q°O¿ý¡B¿é¤J¹qÀ£¡B
¤Î¿é¥X¹qÀ£ ...... µ¥µ¥¡C¬Ý°_¨Ó¦ü¥G {\ttfamily smupsd-0.7-1.i386.rpm} µ{¦¡
(¨£ \ref{software} {(³nÅé)}¤@¸`) ¥i¥H°µ¨ì³o¨Ç¡C
¹ï©ó¨ä¥Lªº³nÅé§Ú«h¤£´±½T©w¡C

¥H¤Uªº¤º®e§Ú±NºÉ¶q»±­­©ó¦p¦ó½Õ¾ã±zªº¨t²Î¨Ï¨ä¯à»P³æ½Õ¼Ò¦¡¤Uªº UPS ¤@°_¤u§@¡C
¦Ó¹ïÁo©ú¼Ò¦¡ªº UPS ¦Ó¨¥¡A°ò¥»·Qªk¬O¤@¼Ëªº¡A¦ý»Ý­n¤°»ò¼Ëªº {\ttfamily powerd} 
°Ñ»P¤u§@¥H¤Î±z»Ý­n¤°»ò¼Ëªº°T¸¹Æl½u¬OÀHµÛ UPS ¦Ó¦³¤£¦Pªº¡C






\section{³nÅé\label{software}}

°ò¥»¤W¡A±z©Ò»Ýªº´N¬O¤@­Ó¥i¥H¤u§@ {\ttfamily powerd} µ{¦¡ÀÉ¡A³q±`±z¥i¥H¦b
{\ttfamily /sbin/powerd} ¤U§ä¨ì¥¦¡C¥¦³q±`¬OÄÝ©ó {\ttfamily SysVinit} ¨t²Îªº¤@³¡¤À¡C
´N§Ú©Òª¾¡A©Ò¦³ªñ´Áª©¥»ªº Linux ¨t²Î³£¥]§t¤F¤@­Ó¸û·sª©ªº {\ttfamily SysVinit} ¡C
¦ý¦b«D±`ÂÂªºª©¥»«h¤£¥]§t {\ttfamily powerd}¡C

°ß¤@ªº°ÝÃD¬O±zªº°T¸¹Æl½u¥i¯à¤£¯à»P±zªº {\ttfamily powerd} ³]©w¬Û°t¦X¡A
¦b³o±¡ªp¤U±z¥²¶·­«·s°µ¤@±ø°T¸¹Æl½u¡A©ÎªÌ¬O§ä¨Ó¤@¥÷ {\ttfamily powerd.c} 
ÀÉ¨Ã­×§ï¥¦¨Ï±o¥¦¯à°t¦X±zªº°T¸¹Æl½u¤u§@¡C©ÎªÌ¬O¡A
±z¥i¥H¨Ï¥Î¥H¤U©Ò¦Cªº³nÅé¡A¤j³¡¤Àªº³nÅé¤¹³\±z°µ¾A·íªº³]©w¥H°t¦X±zªº°T¸¹Æl½u¡C

´N¹³­è­è©Ò´£¨ìªº¡A°£¤F¨Ï¥Î {\ttfamily SysVinit} ªº {\ttfamily powerd} 
¤§¥~±z¤]¥i¥H®³²{¦³ªº¥ô¦ó¤@ºØ UPS ³nÅé¨Ó¥Î¡C¥Ø«e¦³³\¦h³nÅé¥i¥HÀ°§U±z«Ø¥ß¹q¸£»P
UPS ¤§¶¡ªº³s½u¡C¦b§Ú²Ä¤@¦¸¼g³o½g HOWTO ®É³£ÁÙ¨S¦³³o¨Ç³nÅé¡A
¦Ó³o¤]¬O¬°¤°»ò§Ú­n¼g³o½g HOWTO ¡C¨Æ¹ê¤W¡A±z¤]¥i¥H±q¤¤¿ï¤@­Ó³nÅé¨Ó¥Î¡A
¦Ó§¹¥þ©¿²¤³o½g HOWTO ªº¤º®e¡C

¦b 1997 ¦~ 3 ¤ë 15 ¤é¥ª¥k¡A \nameurl{http://sunsite.unc.edu:/pub/Linux/system/ups}{Sunsite ªº UPS ¥Ø¿ý} 
¤U¥i¥H§ä¨ì¤@¤j°ïªº³nÅé¥i¥Î¡C¦Ó¦b¨ä¥Lªººô¯¸¦ü¥G¤]¦³ UPS ±±¨î³nÅé¥i¥H§ä¨ì¡C
¥H¤U¬O§Ú¥Ø«e©Ò§ä¨ìªº (°£¤F¨ä¤¤¨â­Ó¥H¥~¡A¨ä¥L³£¬O¦b sunsite §ä¨ìªº):

\begin{description}
\item[\nameurl{http://sunsite.unc.edu:/pub/Linux/system/ups/Enhanced_APC_BackUPS.tar.gz}{Enhanced\_APC\_BackUPS.tar.gz}] \mbox{}

³o¬O¤@­Ó¥i¥H±±¨î APC Áo©ú¼Ò¦¡ªº UPS ¡C¬Ý°_¨Ó°ò¥»¤W¬O¨Ì¾Ú BUPS Howto
(¥]§t¤F³o¤@½g) ¡A¦ý¤]¦n¹³¦³¤@¨Ç§C¹q¤OÄµ§iªº¤ä´©¡C



\item[\nameurl{http://sunsite.unc.edu:/pub/Linux/system/ups/Enhanced_APC_UPSD-v1.4.tar.gz}{Enhanced\_APC\_UPSD-v1.4.tar.gz}\label{Enhanced}] \mbox{}

¦b {\ttfamily .lsm} ÀÉ¤¤´£¨ì¥¦±q«e´N¬O¤W¤@­Ó©Ò´£¨ìªº³nÅé¡A
¦ý¨Æ¹ê¤W¥¦¥¿¬O±N¤W¤@­Ó³nÅéªº {\ttfamily .tar.gz} ÀÉ¥]¸Ë¦b¥¦ªº {\ttfamily tar.gz} 
ÀÉ¤§¤º¡C¨º½g¤å¥ó»¡©ú¦³°ÝÃD¡A¬Ý°_¨Ó¥¦¦ü¥G¦P®É¤ä´© APC UPS 
ªºÁo©ú»P³æ½Õ¼Ò¦¡¡A¦ý§Ú¤£´±½T©w¡C



\item[\nameurl{http://sunsite.unc.edu:/pub/Linux/system/ups/apcd-0.5.tar.gz}{apcd-0.5.tar.gz}\label{apcd}] \mbox{}

³o¬O¥t¤@­Ó¥i¥H±±¨î APC UPS ©óÁo©ú¼Ò¦¡¤U¹B§@ªº³nÅé¡C
¬Ý°_¨Ó¦ü¥G¥i¥H¤ä´©¥D/±q¼Ò¦¡
(¤]´N¬O»¡¡A·í°±¹q®É¥i¥H¥Ñ¤@¥x¾÷¾¹°e°T¸¹µ¹¥t¤@¥x¾÷¾¹¥s¥¦Ãö¾÷) ¡C
¬Ý°_¨Ó¦ü¥G¬O¨Ï¥Î¤F UPS ªºÁo©ú¼Ò¦¡¡A¤£¹³¬O¸g¥Ñ modem ªº°T¸¹½u¨Ó±±¨î¡C



\item[\nameurl{ftp://cms180.cmsnet.com/pub/smupsd/}{smupsd directory}\label{smupsd}] \mbox{}

¤S¬O¥t¤@­Ó±±¨î APC UPS ªº³nÅé¡C¬Ý°_¨Ó¥i¥H¦b«D±`Áo©ú (tm) ¼Ò¦¡¤U¾Þ§@
UPS ¡CÁ|¨Ò¨Ó»¡¡A¥¦¥]§t¤F¤@­Ó Java ¹Ï§Î¤¶­±ªº UPS ºÊ±±¤u¨ãµ{¦¡¡C
¸Ó¥Ø¿ý¤U¥]§t¤F¤w½sÄ¶¦nªº RPM §Î¦¡ªº³nÅé (\onlynameurl{ftp://cms180.cmsnet.com/pub/smupsd/smupsd-0.7-1.i386.rpm}) ¡A
¤@­Ó­ì©l½X RPM ®æ¦¡ÀÉ (\onlynameurl{ftp://cms180.cmsnet.com/pub/smupsd/smupsd-0.7-1.src.rpm}) ¡A
¥H¤Î¤@­Óðé§ÚÀÉ®× (\onlynameurl{ftp://cms180.cmsnet.com/pub/smupsd/smupsd-0.7-1.README}) ¡C



\item[\nameurl{http://sunsite.unc.edu:/pub/Linux/system/ups/genpower-1.0.1.tgz}{genpower-1.0.1.tgz}\label{genpower}] \mbox{}

¤@­Ó¤@¯ë¤Æªº UPS ±±¨î³nÅé¡C¥¦¥]§t¤F«Ü¦hºØ UPS ªº³]©w --- ¨âºØ TrippLite
ªº³]©w¡A¥H¤Î¤TºØ APC ªº³]©w¡C¦P®É¤]¥]§t¤F«Ü¦nªº»¡©ú¤å¥ó¡Cª«¶W©Ò­È¡C



\item[\nameurl{http://sunsite.unc.edu:/pub/Linux/system/ups/powerd-2.0.tar.gz}{powerd-2.0.tar.gz}\label{ powerd2}] \mbox{}

¤@­Ó {\ttfamily SysVinit} ªº {\ttfamily powerd} µ{¦¡ªº´À¥N«~¡C
»P¥¦ªº»¡©ú¤å¥ó©Ò´£¨ìªº¬Û¤Ï¡A¥¦¦ü¥G¨S¦³¾ã¦X¨ì {\ttfamily SysVinit} 2.62 
ª©¤¤¡C¥¦ªºÀuÂI¦b©ó¥¦¥i¥H°µ¬°¦b¨ä¥L¾÷¾¹¤W°õ¦æªº {\ttfamily powerd} ªº¦øªAºÝ
(°²¦p±zªº¾÷¾¹¦³³s¤Wºô¸ô¥B¥u¦³¤@­Ó UPS ªº¸Ü) ¡A¦Ó¥B¥¦¥i¥H¥Î³]©wÀÉ¨Ó¶i¦æ³]©w
---- ¬G¨ä­ì©l½X¤£»Ý­×§ï¤Î­«·s½sÄ¶¡C



\item[\nameurl{http://sunsite.unc.edu:/pub/Linux/system/ups/upsd-1.0.tgz}{upsd-1.0.tgz}\label{upsd}] \mbox{}

¥t¤@­Ó {\ttfamily powerd} ªº´À¥N«~¡C¬Ý°_¨Ó¦ü¥G»P powerd-2.0.tar.gz 
¦³³\¦h¬Û¦üªº¯S¦â¡C



\item[\nameurl{http://www.bestpower.com/section/software/checkups.tar}{checkups.tar}\label{checkups }] \mbox{}

³o­Ó³nÅé¬O¥Î¨Ó±±¨î Best UPS ªº¡C¥¦¬Oª½±µ¨Ó¦Û Best ¤½¥qªººô­¶ªº¡C
¥¦¥]§t¤F¦hºØ {\ttfamily unix} ªº¥i°õ¦æÀÉ¡A¦ý§ó­«­nªº¬O¡A¥¦ÁÙ¥]§t¤F­ì©l½X¡A
¬G±z¥i¥H¦b Linux ¤U´ú¸Õ¥¦¡A¦Ó¥B°²¦p¥¦µLªk¤u§@¡A±z¤]¥i¥H¸ÕµÛ­×§ï¥¦¡C
¦¹­ì©l½X¦P®É¥]§t¤F¦b³æ½Õ¼Ò¦¡¤U±±¨î UPS ªº "°ò¥»ÀË´ú" «ü¥O¡A
¥H¤Î¤@¨Ç§óºë¥©ªº "¥ý¶iÀË´ú" «ü¥O --- ·í UPS ¦^³ø»¡¥¦¥u³Ñ X 
¤ÀÄÁªº¹q¤O®É§Yµo¥XÃö¾÷ªº°T¸¹¡A¦Ó¤£¬Oµ¥¨ì X ¤ÀÄÁ«á¹q¤O³£¥Î¥ú¤F¤~¶}©lÃö¾÷¡C
¦¹¥ý¶iÀË´úµ{¦¡¤]·|¦b UPS µo¥X¹³¬O©P³òÀô¹Ò·Å«×¹L°ª¡B±µªñ§C¹q¤O¡B
§C¥æ¬y¹q¿é¥X¡B©ÎªÌ¬O¨Ï¥ÎªÌ´ú¸Õµ¥Äµ§i®ÉÃö³¬¾÷¾¹¡C



\item[\nameurl{http://sunsite.unc.edu:/pub/Linux/system/ups/bestups-0.9.tar.gz}{bestups-0.9.tar.gz}\label{bestups}] \mbox{}

¥i¯à¦b±zÅª¨ì³o½g¤å³¹®É¡A¦¹¦b sunsite ¥i¥H§ä±o¨ìªº³nÅé¤wµo®i±o«Ü¦n¤F¡C
¥¦¬O¤@¹ï¥i¥H¬Û¤¬³q°Tªº¼Ò²Õ¡A¥Î¥H±±¨î Best Ferrups UPS¡C¥¦¥i¥H¦bÁo©ú¼Ò¦¡¤U
±±¨î UPS ¡C¥¦¥i¥H»P powerd-2.0 ¦X§@¾Þ±± --- ³o¤@ÂI¦b·í±z¦³¤@­Ó¤j«¬ªº
Best Ferrups UPS ¤ä´©³s±µ¦bºô¸ô¤W¾÷¾¹ªº¹q¤O®É®æ¥~¦³¥Î¡C



\end{description}




½Ðª`·N§Ú¥u¬O§Ö³t¦aÂsÄý¹L³o¨Ç³nÅé¡C§Ú¨Ã¨S¦³¥Î¥¦­Ì¡A°£¤F¨º­Ó§Ú­Ì¤~¶}©l¨Ï¥Îªº
\nameurl{http://sunsite.unc.edu:/pub/Linux/system/ups/bestups-0.9.tar.gz}{bestups-0.9.tar.gz}
¥H¤Î \nameurl{http://sunsite.unc.edu:/pub/Linux/system/ups/powerd-2.0.tar.gz}{powerd-2.0.tar.gz} ¡A
¨ä¤¤ ``¤~¶}©l'' ·N«ä¬O»¡§Ú­Ì¤~¦b¤W­Ó¬P´Á¥|¶}¨Ï°µ´ú¸Õ¡C




\section{¦Û¤v°Ê¤â«ü«n}

³oùØªº°Q½×¬O°w¹ï³æ½Õ¼Ò¦¡ªº UPS ±±¨î¦Ó¼g´Nªº¡CµM¦Ó¡A
¤j³¡¤Àªº¹Lµ{¹ï³æ½Õªº UPS »PÁo©úªº UPS ´X¥G¬O¤@¼Ëªº¡C³Ì¤jªº¤£¦P¦b©ó UPS
ºÊ±±µ{¦¡ (°ò¥»¤W¬O {\ttfamily powerd}) ¦p¦ó»P UPS ·¾³q¡C

¦b¶}©l¤§«e¡A§Ú«ØÄ³¥H¤Uªº¤u§@¬yµ{:
\begin{itemize}
\item ²¤Åª³o½g¤å¥ó¡C
\item ¤U¸ü¨Ã¼f¬d©Ò¦³¬Ý°_¨Ó¯S§O¾A¦X±zªº UPS ªº³nÅé¡C
\item ¤U¸ü¨Ã¼f¬d©Ò¦³§ó¤@¯ë¤Æªº³nÅé¡C½Ðª`·N¦³¨Ç¸û¤@¯ë¤Æªº³nÅé¨Æ¹ê¤W§ó¬°±j¤j¡B
¦³§ó¦nªº»¡©ú¤å¥ó¡B¥B¤ñ°_¨º¨Ç¸û¯S®íªº³nÅé§ó®e©ö¨Ï¥Î¡C
\item ¦pªG±z¨ÌµMµLªkÅý UPS ¤u§@¡A©Î¬O±zªº¤è¦V¨ÌÂÂ¤£²M·¡¡A
½Ð±z¥J²Ó¾\Åª¥»¤å¡A¨Ã¸Õ¸Õ°µ hack ªº¤u§@ ....
\end{itemize}







\subsection{±z©Ò»Ýªº¤u§@ (Á`µ²)}

\begin{itemize}
\item ±N±zªº¹q¸£±µ¤W UPS ¡C
\item ¥Î¯S®íªº°T¸¹Æl½u±N±zªº¹q¸£ªºªº¦ê¦Cªú»P UPS ³s±µ¦b¤@°_¡C
\item ¦b±zªº¹q¸£¤W¶] {\ttfamily powerd} (©Î¨ä¥LÃþ¦üªº³nÅé) ¡C
\item ³]©w±zªº {\ttfamily init} µ{¦¡¨Ï¥¦¯à¦b powerfail ¤Î powerok 
¨Æ¥óµo¥Í®É°µ¾A·íªº³B²z (¨Ò¦p¤À§O±Ò°Ê {\ttfamily shutdown} µ{§Ç¤Î°±¤î¥¿¦b°õ¦æªº
{\ttfamily shutdown} µ{§Ç)¡C
\end{itemize}





\subsection{³oÀ³¸Ó¬O°µ¤°»ò¤u§@ªº?}



\begin{description}
\item[UPS ªº¤u§@] \mbox{}

·í¹q¤O®ø¥¢®É¡A UPS «ùÄò¨ÑÀ³¹q¸£©Ò»Ýªº¹q¤O¡A
¨Ã¥H°e¥X­«¸m°T¸¹©Î¬O¦b¥¦ªº±±¨îªú¤W¥´¶}³s±µ°T¸¹¥H³qª¾¹q¸£¹q¤O®ø¥¢¤F¡C



\item[°T¸¹Æl½uªº¤u§@] \mbox{}

°T¸¹Æl½u¬O³]­p¬°·í UPS °e¥X­«¸m°T¸¹®É¡A·|¨Ï±o¯S®íªº§Ç¦Cªú±±¨î±µ¸}
(°ò¥»¤W¬O {\ttfamily DCD}) ¥X²{°ª¹q¦ì¡C



\item[Powerd ªº¤u§@] \mbox{}

{\ttfamily powerd} µ{¦¡­t³dºÊµø§Ç¦Cªú¡C¥¦«O«ùµÛ UPS ©Ò»Ý¦Ó¤É°ª / 
­°§C§Ç¦Cªú±±¨î±µ¸}ªº°ª / §C¹q¦ì (°ò¥»¤W¡A {\ttfamily DTR}
±µ¸}¥²¶·«O«ù¦b°ª¹q¦ì¥BÃö³¬ UPS ªº±µ¸}¥²¶·«O«ù¦b§C¹q¦ì) ¡C·í {\ttfamily powerd}
µoÄ±±±¨î±µ¸}ÅÜ¦¨°ª¹q¦ì¡A¥¦·|¦b {\ttfamily /etc/powerfail} ÀÉ¤¤¼g¤J
{\ttfamily FAIL} ³o­Ó¦r¨Ã°e {\ttfamily SIGPWR} °T¸¹µ¹ {\ttfamily init} ¦æµ{¡C
·í±±¨î±µ¸}¦A¦¸ÅÜ¦^§C¹q¦ì®É¡A¥¦·|¦b {\ttfamily /etc/powerfail} 
ÀÉ¤¤¼g¤J {\ttfamily OK} ³o­Ó¦r¨Ã°e {\ttfamily SIGPWR} °T¸¹µ¹ {\ttfamily init} ¡C



\item[Init ªº¤u§@ (°£¤W­z¤§¥~¥¦­t³d©Ò¦³ªº¤u§@)] \mbox{}

·í¥¦±µ¨ì¤F {\ttfamily SIGPWR} °T¸¹¡A¥¦·|ÀË¬d {\ttfamily /etc/powerfail} ÀÉ¡C
¦pªGùØÀY¬O {\ttfamily FAIL} ³o­Ó¦r²´¥¦·|°õ¦æ {\ttfamily /etc/inittab}
ÀÉ¤¤ {\ttfamily powerfail} ¨º¤@¦æªº«ü¥O¡C¦pªGùØÀY¬O {\ttfamily OK} 
³o­Ó¦r¥¦«h°õ¦æ {\ttfamily inittab} ÀÉ¤¤ {\ttfamily powerokwait} ¨º¤@¦æªº«ü¥O¡C



\end{description}





\subsection{¦p¦ó³]©w¦n©Ò¦³ªº¤u§@}



¥H¤U§Ú­Ì°²³]±z¦³¤@±ø¥i¥H©M {\ttfamily powerd} ¥¿±`¤u§@ªº°T¸¹Æl½u¡C
¦pªG±z¤£½T©w±zªº°T¸¹Æl½u¬O§_¥i¥H¤u§@ (©Î¥¦¦p¦ó¤u§@)¡A½Ð°Ñ¦Ò
\ref{hacking} {(°T¸¹Æl½u¤Ï¦V¤ÀªR¤Î­×§ï power.c)}
¤@¸`¡A¨º¨à¦³Ãö©ó¤Ö¨£ªº°T¸¹Æl½u³B²z¤Î­«·s³]©w {\ttfamily powerd.c} ªº¸ê°T¡C
\ref{serial-port} {(§Ç¦Cªú±µ¸}ªº«ü©w)} ¤Î
\ref{ioctl} {(¦³ÃöÅª¼g RS232)} ³o¨â¸`¤]±N¹ï±z¦³À°§U¡C

¦pªG±z»Ý­n»s§@¤@±ø°T¸¹Æl½u¡A½Ð¨£ \ref{make-cable} {(¦p¦ó»s§@°T¸¹Æl½u)} ªº¸Ô²Ó»¡©ú¡A¥H¤Î \ref{ups-specific} {(UPS ¸ê®Æ¸`¿ï)} ¤@¸`¤¤¦³Ãö±zªº UPS ªº¤p¸`¡C
«áªÌ¥i¯à¤]¥]§t¤F»s³y°Ó©Ò´£¨Ñªº°T¸¹Æl½uªº¬ÛÃö¸ê°T¡C
©Î³\±zÀ³¦Ü¤Ö±N \ref{ups-specific} {(UPS ¸ê®Æ¸`¿ï)}
¤¤©Ò¦³ªº¤p¸`ÂsÄý¹L¤@¹M¡A¦]¬°¨C¤@¤p¸`³£·|¦³¤@¨ÇÃB¥~ªº¤@¯ë©Ê¸ê®Æ¯à¹ï±z¦³À°§U¡C

\begin{itemize}
\item ­×§ï {\ttfamily /etc/inittab} ÀÉ¡C¼g¤J¹³¥H¤Uªº¤º®e:

\begin{verbatim}
# What to do when power fails (Halt system & drain battery :):
pf::powerfail:/etc/powerfailscript +5

# If power is back before shutdown, cancel the running shutdown.
pg:0123456:powerokwait:/etc/powerokscript
   
\end{verbatim}

\item ¼g {\ttfamily /etc/powerfailscript} ¤Î {\ttfamily /etc/powerokscript}
³o¨â­Ó script ÀÉ¤À§O¦b¤­¤ÀÄÁ (©Î¨ä¥L±z³ßÅwªº®É¶¡) 
¤§¤º¶i¦æÃö¾÷¤Î°±¤î¥ô¦ó¦s¦bªº {\ttfamily shutdown} µ{§Ç¡C
¨Ì±z©Ò¥Îªº {\ttfamily shutdown} µ{¦¡ª©¥»ªº¤£¦P¡A
¥¦¥i¯à·|¬Û·í³æÂ²¥H¦Ü©ó±z®Ú¥»¤£»Ý¨Ï¥Î script ÀÉ¡A©ÎªÌ¬O¤@¦æ {\ttfamily bash}
ªº script ÀÉ¹³¬O¥H¤U³o¤@¦æ:

\begin{verbatim}
    kill `ps -aux | grep "shutdown" | grep -v grep | awk '{print $2}'`
\end{verbatim}

      
(¬°¤FÁ×§K±z§Ë¿ù¡A¤W¤@¦æ¤¤²Ä¤@­Ó³æ¤Þ¸¹¬O¤Ï¦V³æ¤Þ¸¹¡A²Ä¤G¤Î²Ä¤T­Ó¬O³æ¤Þ¸¹¡A
¦Ó³Ì«á¤@­Ó«h¬°¤Ï¦V³æ¤Þ¸¹¡C)
\item ¥Î¥H¤Uªº©R¥O§i¶D {\ttfamily init} ­«·sÅª¨ú {\ttfamily inittab} ÀÉ¤¤ªº³]©w:


\begin{verbatim}
    telinit q
   
\end{verbatim}

\item ½së® rc.local ÀÉ¦b¶}¾÷®É°õ¦æ {\ttfamily powerd} ¡C¨ä»yªk¦p¤U:

\begin{verbatim}
    powerd <line>
    
\end{verbatim}


¨ä¤¤¡A½Ð±z¦Û¦æ±N {\ttfamily $<$line$>$} ³o­Ó¦r´À´«¦¨ modem 
©Ò³s±µªº§Ç¦Cªú¦W¡A¹³¬O {\ttfamily /dev/cua1}¡C
\item ±N¹q¸£ªº§Ç¦Cªú»P UPS ªº°T¸¹Æl½u¬Û³s¡C½Ð¥ý¤£­n±N¹q¸£ªº¹q·½ª½±µ±µ¨ì 
UPS ¤W¡C
    
\item ±N¤@­Ó¥ú·½ (¦p¿Oªw) ±µ¨ì UPS ¤W¡C
\item °õ¦æ {\ttfamily powerd}¡C
\item ¨Ì·Ó¥H¤Uªº¨BÆJ¶i¦æ´ú¸Õ:
\begin{itemize}
\item ©Þ±¼ UPS ªº´¡ÀY¡C
\begin{itemize}
\item ÀË¬d¸Ó¿Oªw¬O§_¤´µM«GµÛ¡C
\item ÀË¬d {\ttfamily /etc/powerfailscript} ¬O§_¤w¶}©l°õ¦æ¡C
\item ÀË¬d {\ttfamily shutdown} ¬O§_¥¿¦b°õ¦æ¡C
\end{itemize}
\item ±µ¦^ UPS ªº´¡ÀY¡C
\begin{itemize}
\item ÀË¬d¸Ó¿Oªw¬O§_¤´µM«GµÛ¡C
\item ÀË¬d {\ttfamily /etc/powerokscript} ¬O§_¤w¶}©l°õ¦æ¡C
\item ÀË¬d {\ttfamily /etc/powerfailscript} ¬O§_¤w°±¤î°õ¦æ¡C
\item ÀË¬d {\ttfamily shutdown} ¬O§_¤w°±¤î°õ¦æ¡C
\end{itemize}
\item ¦A¦¸©Þ±¼ UPS ªº´¡ÀY¡C©ñµÛ¤£¥hºÞ¥¦¨Ã½T©w¹q¸£¦b¤@¬q®É¶¡«á
¥i¥H¥¿±`Ãö¾÷¡C
\item {\bfseries ¦MÀI¨BÆJ¡C} ¦b©Ò¦³ªº¨BÆJ¬Ý°_¨Ó³£¥¿±`¤§«á¡A
±N¹q¸£¹q·½Ãö³¬¨Ã±N¹q¸£ªº¹q·½±µ¨ì UPS ¤W¡C½Ð°õ¦æ¤@­Ó script
¤j¬ù¨C¬íÄÁ°µ¤@¦¸ sync µwºÐ¸ê®Æ¦^¦sªº°Ê§@¡A¦P®É¤]¶]¥t¤@­Ó script
«ùÄò¥H find «ü¥O·j´M¾ãÁûµwºÐ¡C¨ä¤¤²Ä¤@­Ó script 
¬O¬°¤F½T«O¦w¥þ¡A¦Ó²Ä¤G­Ó«h¬O§Uªø¹q¤Oªº®ø¯Ó¡C²{¦b¡A±N UPS
ªº´¡ÀY©Þ¥X¡A¦A¦¸ÀË¬d {\ttfamily shutdown} ¬O§_¤w¦b¹B§@¡A¨Ãµ¥«Ý¤@¬q®É¶¡¡C
½T©w¹q¸£¦b UPS ªº¹q¤O¥Î§¹«e§¹¥þ¦aÃö¾÷¡C¦¹¤@¨BÆJ¬O«Ü¦MÀIªº¡A
¦]¬°¦pªG UPS ªº¹q¤O¦b¹q¸£§¹¦¨Ãö¾÷¤§«e¥ý¥Î§¹¤F¡A
±zªºÀÉ®×¨t²Î±N·|¨ü·l¡A¥B±z±N¥i¯à¥á¥¢¤@¨ÇÀÉ®×¡C
±z¥i¯à¦b¶i¦æ³o¶µ´ú¸Õ¤§«e·|·Q­n³Æ¥÷±z©Ò¦³ªºÀÉ®×¡A
¨Ã±N¶}©lÃö¾÷ªº®É¶¡³]µu¤@ÂI¥H¶}©l³o¶µ´ú¸Õ¡C
\end{itemize}
\end{itemize}


®¥³ß±z! ±zªº Linux ¨t²Î²{¦b¤w¦b UPS ªº«OÅ@¤U¡A
¥B¥¦±N·|¦b¹q¤O¯ÓºÉ¤§«e¦w¥þ¦aÃö¾÷¤F¡C






\subsection{¶i¤@¨Bªº§ïµ½}



\begin{itemize}
\item ­×§ï {\ttfamily powerd.c} ¨Ï¥¦¦bºÊµø UPS ªº°T¸¹½u®É¯à±oª¾¹q¦À¹q¤O¤w®z¡C
·í¹q¤O·L®z®É¡A°¨¤W¶i¦æºò«æÃö¾÷µ{§Ç¡C
\item ­×§ïÃö¾÷µ{§Ç¨Ï¥¦¦b {\ttfamily powerfail} ±¡ªp¤UÃö¾÷®É¡A
¯à°÷¦b§¹¦¨©Ò¦³¤u§@¤§«á±N UPS Ãö±¼¡C
\end{itemize}





\section{µwÅéªºª`·N¨Æ¶µ}




\subsection{¦p¦ó»s§@°T¸¹Æl½u\label{make-cable}}

¥»¸`ªº¤º®e¥u¬O¨Ç§Ú¦bºô¸ô¤W¬Ý¨ìªº¸ê°T¡C§Ú¨Ã¨S¦³¿Ë¦Û¸Õ¹L¡A
©Ò¥H§ÚµLªk¨Ì§Úªº¸gÅç¼g¤U¨Ó¡C¦pªG¦³¤H¦³¸gÅç¡A³Â·Ð±z¬°§Ú¼g³o¤@¸` :)¡C
¦P®É¤]½Ð±z°Ñ¦Ò \ref{gps1000} {(ACCODATA ªº GPS1000)} ¤¤¦³Ãö 
GPS1000 ªº¸ê®Æ¡A¤£¥²»¡¡A\ref{ups-specific} {(UPS ¸ê®Æ¸`¿ï)}
³o¤@¸`¤¤©Ò¦³¯S®í UPS ªº¸ê®Æ¤]¬O­È±o°Ñ¦Òªº¡C

\begin{verbatim}
   >From miquels@caution.cistron.nl.mugnet.org Wed Jul 21 14:26:33 1993
   Newsgroups: comp.os.linux
   Subject: Re: UPS interface for Linux?
   From: miquels@caution.cistron.nl.mugnet.org (Miquel van Smoorenburg)
   Date: Sat, 17 Jul 93 18:03:37
   Distribution: world
   Organization: Cistron Electronics.

   In article <1993Jul15.184450.5193@excaliber.uucp>
   joel@rac1.wam.umd.edu (Joel M. Hoffman) writes:
   > §Ú¥¿¥´ºâ­nÁÊ¶R UPS (¤£Â_¹q¨t²Î)¡A§Úª`·N¨ì¦³¨Ç¨ã¦³ LAN ªº¤¶­±¡A
   > ¥i¥H¦b°±¹q®É¦V LAN °e°T¸¹¡C
   >
   > ¦Ó Linux ¦³¨S¦³³o¼Ëªº¤¶­±©O?
   >
   > ÁÂÁÂ±zªº¦^µª¡C
   >
   >-Joel
   >(joel@wam.umd.edu)
   >

   ·í§Ú¦b­×§ï¤W¤@ª©ªº SysVinit ®É (²{¦bªºª©¥»¬O 2.4)¡A
   ¨º®É§Úªº¹q¸£¦³¤@­Ó UPS ¡A©Ò¥H§Ú¥[¤J¤F¹ï¥¦ªº¤ä´©¡C
   ±z¤]³\¤w¦b³Ìªñªº¤@­Ó <signal.h> ¼ÐÀYÀÉ¤¤¬Ý¨ì¤F #define SIGPWR 30
   ³o¤@¦æ :-)¡CÁ`¤§¡A§Ú¨Ã¨S¦³¨º­Ó¯S®íªº¤¶­±¡A¦ý¤j¦h¼Æªº UPS
   ¬O¾a²£¥Í©Î¤¤Â_¤@­Ó¹q·½¤¤Â_°T¸¹¦b¹B§@ªº¡C
   §Ú·Q¨ì¤@­ÓÂ²³æªº¤è¦¡¥i¥H±N¥¦ªº°T¸¹½u³s±µ¨ì¹q¸£°T¦Cªúªº DCD
   ±µ¸}¡C¦b SysVinit ®M¥ó¤¤¦³¤@­Ó¥s°µ 'powerd' 
   ªº±`¾nµ{¦¡¥i¥H°lÂÜ¨ÃºÊµø¸Ó°T¸¹½u¡A·í°T¸¹ªºª¬ºA§ïÅÜ®É¥¦·|°e¤@­Ó SIGPWR
   ªº°T¸¹µ¹ init µ{¦¡¡A¦]¦¹ init «K¥i¥H±Ä¨ú¾A·íªº¦æ°Ê (¹³¬O¦b 5
   ¤ÀÄÁ¤§«áÅý¨t²ÎÃö¾÷) ¡C¦p¦ó±N°T¸¹½u»P UPS ¬Û³s¦b "powerd.c"
   ¤w¦³»¡©ú¡A¦ý§ÚÁÙ¬O¹Ï¥Ü¦p¤U¥H°µ¬°¸ÑÄÀ:


                        +------------------------o  DTR
                        |
                      +---+
                      |   | resistor
                      |   | 10 kilo-Ohm
                      |   |
                      +---+                                To serial port.
                        |
          +-----o-------+------------------------o  DCD
          |             |
          o  UPS        |
        \    relais     |
         \              |
          |             |
          +-----o-------+------------------------o  GND

   µe±oÁÙ¥i¥H¶Ü?

   §Æ±æ³o¼Ë·|¦³À°§U¡C

   SysVinit ¥i¥H¦b sunsite (©Î¥i¯à¦b tsx-11) ¤U§ä¨ì¡AÀÉ¦W¬O 
   SysVinit2.4.tar.z ¡C

   Mike.

   --

   Miquel van Smoorenburg, <miquels@cistron.nl.mugnet.org>
   Ibmio.com: cannot open CONFIG.SYS: file handle broke off.


   >From danny@caution.cistron.nl.mugnet.org Wed Jul 21 14:27:04 1993
   Newsgroups: comp.os.linux
   Subject: Re: UPS interface for Linux?
   From: danny@caution.cistron.nl.mugnet.org (Danny ter Haar)
   Date: Mon, 19 Jul 93 11:02:14
   Distribution: world
   Organization: Cistron Electronics.

   In article <9307174330@caution.cistron.nl.mugnet.org>
   miquels@caution.cistron.nl.mugnet.org (Miquel van Smoorenburg) writes:
   > ¦p¦ó±N°T¸¹½u»P UPS ¬Û³s¦b "powerd.c" ¤w¦³»¡©ú¡A
   > ¦ý§ÚÁÙ¬O¹Ï¥Ü¦p¤U¥H°µ¬°¸ÑÄÀ:

   ¸Ó¹Ï¥Ü¨Ã¤£¤Q¤À²M·¡¡A½Ð§ï¥Î¥H¤Uªº¹Ï¥Ü!
   >
   >                     +------------------------o  DTR
   >                     |
   >                   +---+
   >                   |   | resistor
   >                   |   | 10 kilo-Ohm
   >                   |   |
   >                   +---+                                To serial port.
   >                     |
   >       +-----o-------+------------------------o  DCD
   >       |
   >       o  UPS
   >     \    relais
   >      \
   >       |
   >       +-----o--------------------------------o  GND
   >

   ¨ä¤¤ DTR ±µ¸}¬O«O«ù¦b°ª¹q¦ì¡A«h·í UPS ªº¥~¬É¿é¤J¹q·½®ø¥¢®É¡A
   ¨º­Ó¶}Ãö (relais) ·|Ãö³¬¡C¦Ó¹q¸£«K¬OºÊµø DCD ¿é¤J±µ¸}¡Aµ¥µÛ¥¦ÅÜ¦¨§C¹q¦ì¡C
   ·í¨Æ±¡µo¥Í®É¥¦±N·|±Ò°ÊÃö¾÷µ{§Ç ...

   _____
   Danny

   --
   <=====================================================================>
   Danny ter Haar  <dannyth@hacktic.nl> or <danny@cistron.nl.mugnet.org>
   Robins law #103: 'a couple of lightyears can't part good friends'
\end{verbatim}





\subsection{°T¸¹Æl½u¤Ï¦V¤ÀªR¤Î­×§ï power.c\label{hacking}}







\end{document}
