<var id="3af57"><output id="3af57"></output></var>
    <var id="3af57"><sup id="3af57"></sup></var>
    <ruby id="3af57"><kbd id="3af57"><nobr id="3af57"></nobr></kbd></ruby>

    <var id="3af57"><output id="3af57"></output></var>
      <sub id="3af57"></sub>

    1. 當前位置:博客首頁>>樹莓派 >> 閱讀正文

      樹莓派安裝homebridge小記

      作者: 鄭曉 分類: 樹莓派 發布于: 2018-08-02 08:35 瀏覽:84,844 評論(3)


      樹莓派3B+ 系統Raspbian

      設置國內源

      sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
      sudo vi /etc/apt/sources.list
      # 這里從網上找國內源復制進文件中保存

      安裝homebridge

      sudo apt-get update
      sudo apt-get install npm
      sudo npm install -g n
      sudo n stable

      # 升級node 因為安裝yeelight插件時有限制node版本
      sudo apt-get install libavahi-compat-libdnssd-dev

      sudo npm install -g --unsafe-perm homebridge hap-nodejs node-gyp
      cd /usr/local/lib/node_modules/homebridge/
      sudo npm install --unsafe-perm bignum
      # 以下網上搜的命令最后是mdns 但我并沒有這個目錄,我從ed25519-hap目錄中找到了同樣的gyp文件
      cd /usr/local/lib/node_modules/hap-nodejs/node_modules/ed25519-hap/
      sudo node-gyp BUILDTYPE=Release rebuild
      sudo npm install -g homebridge-yeelight

      # 安裝完成 執行以下代碼運行測試 會生成二維碼 使用iOS上的家庭,添加設備,掃碼完成添加。
      /usr/local/bin/homebridge

      配置homebridge的自啟動

      sudo vi /etc/init.d/homebridge

      添加以下代碼

      #!/bin/sh
      dir="/home/pi"
      cmd="DEBUG=* /usr/local/bin/homebridge"
      user="pi"

      name=`basename $0`
      pid_file="/var/run/$name.pid"
      stdout_log="/var/log/$name.log"
      stderr_log="/var/log/$name.err"

      get_pid() {
          cat "$pid_file"
      }

      is_running() {
          [ -f "$pid_file" ] && ps -p `get_pid` > /dev/null 2>&1
      }

      case "$1" in
          start)
          if is_running; then
              echo "Already started"
          else
              echo "Starting $name"
              cd "$dir"
              if [ -z "$user" ]; then
                  sudo $cmd >> "$stdout_log" 2>> "$stderr_log" &
              else
                  sudo -u "$user" $cmd >> "$stdout_log" 2>> "$stderr_log" &
              fi
              echo $! > "$pid_file"
              if ! is_running; then
                  echo "Unable to start, see $stdout_log and $stderr_log"
                  exit 1
              fi
          fi
          ;;
          stop)
          if is_running; then
              echo -n "Stopping $name.."
              kill `get_pid`
              for i in 1 2 3 4 5 6 7 8 9 10
              # for i in `seq 10`
              do
                  if ! is_running; then
                      break
                  fi

                  echo -n "."
                  sleep 1
              done
              echo
              if is_running; then
                  echo "Not stopped; may still be shutting down or shutdown may have failed"
                  exit 1
              else
                  echo "Stopped"
                  if [ -f "$pid_file" ]; then
                      rm "$pid_file"
                  fi
              fi
          else
              echo "Not running"
          fi
          ;;
          restart)
          $0 stop
          if is_running; then
              echo "Unable to stop, will not attempt to start"
              exit 1
          fi
          $0 start
          ;;
          status)
          if is_running; then
              echo "Running"
          else
              echo "Stopped"
              exit 1
          fi
          ;;
          *)
          echo "Usage: $0 {start|stop|restart|status}"
          exit 1
          ;;
      esac
      exit 0

      最后

      sudo chmod 755 /etc/init.d/homebridge
      sudo update-rc.d homebridge defaults
      # 完成 使用以下命令可啟動服務,斷電開機時也會自動啟動
      sudo /etc/init.d/homebridge start

      ————————-
      期間的history記錄

        108  node
        109  sudo apt-get install libavahi-compat-libdnssd-dev
        110  sudo npm install -g homebridge-yeelight
        111  sudo apt-get install npm
        112  sudo vi /etc/apt/sources.list
        113  sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
        114  sudo vi /etc/apt/sources.list
        115  sudo apt-get install npm
        116  sudo apt-get update
        117  sudo apt-get install npm
        118  sudo npm install -g homebridge-yeelight
        119  n -V
        120  sudo npm install -g n
        121  n -V
        122  sudo n -V
        123  sudo n stable
        124  sudo apt-get install libavahi-compat-libdnssd-dev
        125  sudo npm install -g homebridge-yeelight
        126  ls -a
        127  homebridge
        128  sudo npm install -g --unsafe-perm homebridge hap-nodejs node-gyp
        129  cd /usr/local/lib/node_modules/homebridge/
        130  sudo npm install --unsafe-perm bignum
        131  cd /usr/local/lib/node_modules/hap-nodejs/node_modules/mdns
        132  cd /usr/local/lib/node_modules/hap-nodejs/node_modules/multicast-dns
        133  ls
        134  cd ..
        135  sudo node-gyp
        136  sudo node-gyp BUILDTYPE=Release rebuild
        137  sudo npm install -g homebridge-yeelight
        138  cd /usr/local/lib/node_modules/hap-nodejs/node_modules/ed25519-hap/
        139  ls
        140  sudo node-gyp BUILDTYPE=Release rebuild
        141  /usr/local/bin/homebridge
        142  exit
        143  sudo vi /etc/init.d/homebridge
        144  sudo chmod 755 /etc/init.d/homebridge
        145  sudo update-rc.d homebridge defaults
        146  sudo vi /etc/init.d/homebridge
        147  sudo update-rc.d homebridge defaults
        148  sudo /etc/init.d/homebridge start
        149  sudo reboot
        150  history
      ? ? ? ?

      本文采用知識共享署名-非商業性使用 3.0 中國大陸許可協議進行許可,轉載時請注明出處及相應鏈接。

      本文永久鏈接: http://www.htrpzf.cn/raspberry-homebridge.html

      樹莓派安裝homebridge小記:目前有3 條留言

      用戶評論頭像 丁八塊發表于 2018年11月12日 15:33[回復]

      我是來試試名字的

      用戶評論頭像 ljx發表于 2018年08月09日 09:10[回復]

      樓主用的是什么富文本編輯器呢,看起來縮進上對代碼的支持不太好

      用戶評論頭像 php讀取word求助發表于 2018年08月02日 15:00[回復]

      博主,你好!php讀取word求助,按照這個教程antiword-read-word-doc.html,讀取出來的word是純文本的,能否保留原排版格式 呢

      發表評論

      change vcode

      337p日本欧洲亚洲大胆_日韩欧美精品视频播放一区二区_国产精品自拍第一页_国产三级精品三级在线

        <var id="3af57"><output id="3af57"></output></var>
        <var id="3af57"><sup id="3af57"></sup></var>
        <ruby id="3af57"><kbd id="3af57"><nobr id="3af57"></nobr></kbd></ruby>

        <var id="3af57"><output id="3af57"></output></var>
          <sub id="3af57"></sub>