入坑HA. 记录安装home assistant (docker)

先买了个智能灯泡,买回家发现需要一个zigbee的网关.搜了一下,买了个conbee II的usb 网关,.然后需要台电脑,手上没有树莓派,所以找了一台闲置了多年的旧富士康的上网本nt-330来做.CPU是inter ATOM 支持amd64架构,2G内存,256G硬盘.先重装了ubuntu 18. 然后安装conBee II的驱动.测试可用.然后开始安装home assistant.

官网多都是给树莓派写的,一般直接给镜像.给linux不太详细.我先尝试安装官方对unbuntu用户的指引:https://www.home-assistant.io/hassio/installation/ 

不太成功.最后搜到用docker完成的例子:

https://community.home-assistant.io/t/installing-home-assistant-on-ubuntu-18-10/95732

sudo -i
add-apt-repository universe
apt-get update
apt-getinstall -y apparmor-utils apt-transport-https avahi-daemon ca-certificates curl dbus jq network-manager socat software-properties-common
curl -fsSL get.docker.com | sh
curl -sL “https://raw.githubusercontent.com/home-assistant/hassio-build/master/install/hassio_install” | bash -s

最后一句出错,按后搜索,根据提示需要更新即可
https://github.com/home-assistant/hassio-installer

新的命令是:

curl -sL https://raw.githubusercontent.com/home-assistant/hassio-installer/master/hassio_install.sh | bash -s

安装完成

打开8123端口即可使用HA了.

高手就是高手

今天家里来了一个高手.我手上有台旧的笔电,装的mint linux密码忘了,闲置很久了. 问他除了重装还有啥办法,他说grub 里启动命令里去掉slash加上init=/bin/bash 或者/bin/sh 启动后然后就直接root了.

启动后我登录升级,发现systemd-udevd占据cpu过高.问他怎么办,他查了一下,是ubuntu普遍问题,是blueZ的缺陷,去blueZ现在最新的补丁(8小时前刚刚放出),然后升级内核从4.15升级到5.00.重启问题消失.

佩服佩服

解码heidiSql的密码

先导出heidisql的设置到文本文件. 然后找出密码字段,放到以下的js 去解码.

function heidiDecode(hex) {
    var str = '';
    var shift = parseInt(hex.substr(-1));
    hex = hex.substr(0, hex.length - 1);
    for (var i = 0; i < hex.length; i += 2) {
        str += String.fromCharCode(parseInt(hex.substr(i, 2), 16) - shift);
    }
    return str;
}

来源: http://www.chasewoodford.com/blog/how-to-recover-a-stored-password-from-heidisql/

ZF1的DB语法文档和查询实际的query

是的,我还在用zF1,而且还需要查文档.这是ZF1的数据库相关的文档,每次写都要看.

https://framework.zend.com/manual/1.12/en/zend.db.select.html

另外,我还需要查看数据库到底执行了哪些查询,需要打开log

  1. Execute SET GLOBAL log_output = 'TABLE';
  2. Execute SET GLOBAL general_log = 'ON';
  3. Take a look at the table mysql.general_log

来源:https://stackoverflow.com/questions/650238/how-to-show-the-last-queries-executed-on-mysql 

但是在heidi里看到的argument还是hex,还要用个开关来转为txt.

https://www.heidisql.com/forum.php?t=24486

这样终于看到实际执行的sql了.

Vagrant的VBoxGuestAddition版本升级(debian)

在升级VirtualBox以后,vagrant up的时候GuestAddition版本不对。需要重新安装VBoxGutestAddtion.

手动安装:

1 vagrant up先启动虚拟机(debian), 然后ssh进入,切换到/opt/VBoxGuestAddtion-x.x.x下,用sudo 运行unistanll.sh

2 下载新的版本 , 比如

wget http://download.virtualbox.org/virtualbox/5.2.18/VBoxGuestAdditions_5.2.18.iso

然后mount 这个iso, 进行安装

sudo mkdir -p /mnt/disk
sudo mount -o loop VBoxGuestAdditions_5.2.18.iso /mnt/disk
cd /mnt/disk
sudo ./VBoxLinuxAdditions.run
sudo reboot

退出后重新启动vagrant up 就提示正常了。

今天的收获

定了新机器,在ubuntu18上装了php5.6,然后发现数据库5.7不行,然后看了教程1手动安装了mysql 5.5 (教程地址在最后)然后在设计root密码上耽误点时间,看了教程2后,手动设置了root密码.

教程1 手动降级mysql5.7到5.5
https://askubuntu.com/questions/763240/is-it-possible-to-install-mysql-5-5-or-5-6-on-ubuntu-16-04

教程2 手动覆盖mysql root密码.注意5.7 和5.5用来保存密码的字段的不同
https://www.techrepublic.com/article/how-to-set-change-and-recover-a-mysql-root-password/