Recipe for MCP Weather Server

Intel NUC with Samsung Pro 850 SSD

  • base netinst install of jessie - deselect everything from tasksel
    • hostname weather-server – domain mcp.lcl
    • default partition layout
  • > /etc/motd
  • apt-get --no-install-recommends install aptitude
  • aptitude install ssh (this will pull in xauth, but that's okay)
  • aptitude install less fbset screen rsync psmisc file patch ethtool strace tcpdump vim bzip2 xz-utils
  • aptitude --without-recommends install dnsutils
  • adduser tdobes adm
  • adduser tdobes systemd-journal
  • aptitude install dbus
  • sed -i -e 's/^deb.* main$/& contrib non-free/g' /etc/apt/sources.list
  • aptitude update && aptitude forget-new
  • aptitude install intel-microcode
  • aptitude install firmware-iwlwifi # for Intel WLAN card
  • aptitude install firmware-realtek # for Realtek NIC
  • aptitude install ifplugd
  • sed -i -e 's/^INTERFACES=""/INTERFACES="eth0"/g' /etc/default/ifplugd
  • sed -i -e 's/^allow-hotplug eth0/#allow-hotplug eth0/g' /etc/network/interfaces
  • aptitude --without-recommends install ntp
    echo '[Unit]' > /etc/systemd/system/ntp.service
    echo 'Description=Network Time Protocol daemon' >> /etc/systemd/system/ntp.service
    echo 'After=network.target' >> /etc/systemd/system/ntp.service
    echo >> /etc/systemd/system/ntp.service
    echo '[Service]' >> /etc/systemd/system/ntp.service
    echo 'ExecStart=/usr/sbin/ntpd -n -g -u ntp:ntp' >> /etc/systemd/system/ntp.service
    echo >> /etc/systemd/system/ntp.service
    echo '[Install]' >> /etc/systemd/system/ntp.service
    echo 'WantedBy=multi-user.target' >> /etc/systemd/system/ntp.service
    systemctl enable ntp.service
  • mkdir -p /etc/systemd/system/ssh.socket.d
    echo '[Socket]' > /etc/systemd/system/ssh.socket.d/port-2222.conf
    echo 'ListenStream=2222' >> /etc/systemd/system/ssh.socket.d/port-2222.conf
    systemctl disable ssh.service && systemctl enable ssh.socket
  • mkdir -p /etc/systemd/system/getty\@tty1.service.d
    echo '[Service]' > /etc/systemd/system/getty\@tty1.service.d/noclear.conf
    echo 'TTYVTDisallocate=no' >> /etc/systemd/system/getty\@tty1.service.d/noclear.conf
  • systemctl mask networking.service # we use ifplugd instead
    echo 'D /run/network 0755 root root' > /etc/tmpfiles.d/debian-networking.conf
    echo 'F /run/network/ifstate 0644 root root - lo=lo' >> /etc/tmpfiles.d/debian-networking.conf
  • aptitude purge acpid acpi-support-base # systemd-logind takes care of this
  • aptitude install wpasupplicant ifmetric iw wireless-tools
  • echo 'ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev' > /etc/wpa_supplicant/mcp.conf
    echo 'update_config=1' >> /etc/wpa_supplicant/mcp.conf
    echo >> /etc/wpa_supplicant/mcp.conf
    echo 'network={' >> /etc/wpa_supplicant/mcp.conf
    echo '  ssid="mcp-5.8"' >> /etc/wpa_supplicant/mcp.conf
    echo '  scan_ssid=1' >> /etc/wpa_supplicant/mcp.conf
    echo '  key_mgmt=WPA-PSK' >> /etc/wpa_supplicant/mcp.conf
    echo '  psk="**PASSWORD**"' >> /etc/wpa_supplicant/mcp.conf
    echo '  priority=10' >> /etc/wpa_supplicant/mcp.conf
    echo '  id_str="mcp"' >> /etc/wpa_supplicant/mcp.conf
    echo '}' >> /etc/wpa_supplicant/mcp.conf
    echo >> /etc/wpa_supplicant/mcp.conf
    echo 'network={' >> /etc/wpa_supplicant/mcp.conf
    echo '  ssid="mcp-2.4"' >> /etc/wpa_supplicant/mcp.conf
    echo '  scan_ssid=1' >> /etc/wpa_supplicant/mcp.conf
    echo '  key_mgmt=WPA-PSK' >> /etc/wpa_supplicant/mcp.conf
    echo '  psk="**PASSWORD**"' >> /etc/wpa_supplicant/mcp.conf
    echo '  priority=9' >> /etc/wpa_supplicant/mcp.conf
    echo '  id_str="mcp"' >> /etc/wpa_supplicant/mcp.conf
    echo '}' >> /etc/wpa_supplicant/mcp.conf
    chmod 600 /etc/wpa_supplicant/mcp.conf # protect password
    echo >> /etc/network/interfaces
    echo 'allow-hotplug wlan0' >> /etc/network/interfaces
    echo 'iface wlan0 inet manual' >> /etc/network/interfaces
    echo '  wpa-roam /etc/wpa_supplicant/mcp.conf' >> /etc/network/interfaces
    echo >> /etc/network/interfaces
    echo 'iface mcp inet dhcp' >> /etc/network/interfaces
    echo '  metric 1' >> /etc/network/interfaces
  • sed -i -e 's/^GRUB_CMDLINE_LINUX_DEFAULT="quiet"$/GRUB_CMDLINE_LINUX_DEFAULT="quiet panic=5"/g' /etc/default/grub && update-grub
  • systemctl mask systemd-rfkill@rfkill0.service
    systemctl mask keyboard-setup.service
    systemctl mask console-setup.service
    systemctl mask rc-local.service
  • aptitude --without-recommends install irqbalance
  • aptitude install lm-sensors
  • aptitude install python-serial picocom
  • aptitude install mariadb-server # (and set root password when prompted)
  • aptitude install python-mysqldb
  • aptitude install git
  • aptitude install python-cheetah python-configobj python-imaging python-usb
  • adduser tdobes dialout
  • aptitude install apache2 php5-fpm
  • a2enmod proxy_fcgi
  • echo 'ProxyPassMatch ^/(.*\.php(/.*)?)$ unix:/var/run/php5-fpm.sock|fcgi://127.0.0.1/var/www/html/ disablereuse=off' > /etc/apache2/mods-enabled/proxy-php5-fpm.conf # note: apache docs talk about enablereuse=on, but apparently that was added in 2.4.11 and jessie is on 2.4.10; supposedly this does the same thing? # does not pass through special characters (e.g. spaces) properly
  • # This apache 2.4/php-fpm configuration works properly with paths including spaces (unlike the deleted one above). See https://wiki.archlinux.org/index.php/Apache_HTTP_Server#Using_php-fpm_and_mod_proxy_fcgi and comments on http://php.net/manual/en/features.http-auth.php about SetEnvIf line
    echo '<FilesMatch \.php$>' > /etc/apache2/mods-enabled/proxy-php5-fpm.conf
    echo '  SetHandler "proxy:unix:/var/run/php5-fpm.sock|fcgi://localhost/"' >> /etc/apache2/mods-enabled/proxy-php5-fpm.conf
    echo '  SetEnvIf Authorization .+ HTTP_AUTHORIZATION=$0' >> /etc/apache2/mods-enabled/proxy-php5-fpm.conf # gets apache to pass http auth credentials to PHP
    echo '</FilesMatch>' >> /etc/apache2/mods-enabled/proxy-php5-fpm.conf
    echo '<Proxy "fcgi://localhost/" disablereuse=off max=10>' >> /etc/apache2/mods-enabled/proxy-php5-fpm.conf
    echo '</Proxy>' >> /etc/apache2/mods-enabled/proxy-php5-fpm.conf
  • systemctl restart apache2
  • rm /var/www/html/index.html
  • aptitude install phpmyadmin php5-mysqlnd # select apache2 when prompted, tell it yes to configure database, enter database root password, then leave application password blank (auto-generates random password)
  • aptitude install fonts-freefont-ttf # needed for Bootstrap theme
  • #### wget http://www.weewx.com/downloads/weewx_3.6.1-1_all.deb
    #### dpkg -i weewx_3.6.1-1_all.deb
    wget -qO - http://weewx.com/keys.html | apt-key add -
    wget -qO /etc/apt/sources.list.d/weewx.list http://weewx.com/apt/weewx.list
    aptitude update && aptitude forget-new && aptitude install weewx
    # location: Merrillville, IN
    # lat,long: 41.489498, -87.333031
    # altitude: 680, foot
    # display units: US
    # weather station type: Ultimeter
    # weather station model: Ultimeter 2100
    # serial port: /dev/ttyUSB0
  • mysqladmin -p create weewx
  • echo "grant all on weewx.* to weewx@localhost identified by 'McpWeewx864';" | mysql -p
  • sed -i -e 's/password = weewx$/password = McpWeewx864/g' -e 's/database = archive_sqlite$/database = archive_mysql/g' /etc/weewx/weewx.conf
  • systemctl restart weewx
  • rm /var/lib/weewx/weewx.sdb
  • wee_extension –install v2.24.tar.gz
computer/mcp_weather_server.txt · Last modified: 2018/06/23 14:22 by tdobes
Recent changes RSS feed Driven by DokuWiki Valid XHTML 1.0 Valid CSS