## arg 1: the new package version #pre_install() { # do something here #} # arg 1: the new package version post_install() { echo "changing the remote GIT source to BARE on node" cd /opt/ethoscope-device git remote set-url origin git://node/ethoscope.git echo "setting GIT branch" git checkout dev echo "installing python package" cd /opt/ethoscope-device/src python setup.py develop echo "create 000 machine files" echo "ETHOSCOPE_000" > /etc/machine-name echo "ETHOSCOPE_000" > /etc/hostname echo "create a default wlan0 file" echo "Description='ethoscope_wifi'" > /etc/netctl/wlan echo "Interface=wlan0" >> /etc/netctl/wlan echo "Connection=wireless" >> /etc/netctl/wlan echo "Security=wpa" >> /etc/netctl/wlan echo "IP=dhcp" >> /etc/netctl/wlan echo "TimeoutDHCP=60" >> /etc/netctl/wlan echo "ESSID=ETHOSCOPE_WIFI" >> /etc/netctl/wlan echo "Key=ETHOSCOPE_1234" >> /etc/netctl/wlan echo "create a default eth0 file" echo "Description='Ethernet'" > /etc/netctl/ether echo "Interface=eth0" >> /etc/netctl/ether echo "Connection=ethernet" >> /etc/netctl/ether echo "IP=dhcp" >> /etc/netctl/ether echo "use netctl instead of networkd" systemctl stop systemd-networkd systemctl disable systemd-networkd ip link set eth0 down ip link set wlan0 down netctl enable ether netctl enable wlan # netctl-auto is for wireless connections only, systemctl start netctl-auto@wlan systemctl enable netctl-auto@wlan # ifplugd for wired connections systemctl enable netctl-ifplugd@eth0 systemctl start netctl-ifplugd@eth0 echo "configure the NTP file" echo 'server node' > /etc/ntp.conf echo 'server 127.127.1.0' >> /etc/ntp.conf echo 'fudge 127.127.1.0 stratum 10' >> /etc/ntp.conf echo 'restrict default kod limited nomodify nopeer noquery notrap' >> /etc/ntp.conf echo 'restrict 127.0.0.1' >> /etc/ntp.conf echo 'restrict ::1' >> /etc/ntp.conf echo 'driftfile /var/lib/ntp/ntp.drift' >> /etc/ntp.conf echo "enabling DEVICE specific systemd service files" systemctl enable ethoscope_device.service ethoscope_listener.service ethoscope_update.service systemctl enable ntpd.service mysqld.service sshd.service mysqld.service avahi-daemon.service #systemctl enable fake-hwclock fake-hwclock-save.timer echo "Set up mysql database" mysql_install_db --user=mysql --basedir=/usr --datadir=/var/lib/mysql systemctl start mysqld.service mysql -u root -e "CREATE USER 'ethoscope'@'localhost' IDENTIFIED BY 'ethoscope'" mysql -u root -e "CREATE USER 'ethoscope'@'%' IDENTIFIED BY 'ethoscope'" mysql -u root -e "GRANT ALL PRIVILEGES ON *.* TO 'ethoscope'@'localhost' WITH GRANT OPTION"; mysql -u root -e "GRANT ALL PRIVILEGES ON *.* TO 'ethoscope'@'%' WITH GRANT OPTION"; chown -R mysql:mysql /var/lib/mysql echo "setup mariadb configuration" echo '[server]' > /etc/my.cnf.d/server.cnf echo 'log-bin=mysql-bin' >> /etc/my.cnf.d/server.cnf echo 'binlog_format=mixed' >> /etc/my.cnf.d/server.cnf echo 'expire_logs_days = 10' >> /etc/my.cnf.d/server.cnf echo 'max_binlog_size = 100M' >> /etc/my.cnf.d/server.cnf echo "install picamera settings into the boot/config.txt" echo 'start_file=start_x.elf' > /boot/config.txt echo 'fixup_file=fixup_x.dat' >> /boot/config.txt echo 'disable_camera_led=1' >> /boot/config.txt echo 'gpu_mem=256' >> /boot/config.txt echo 'cma_lwm=' >> /boot/config.txt echo 'cma_hwm=' >> /boot/config.txt echo 'cma_offline_start=' >> /boot/config.txt echo 'hdmi_force_hotplug=1' >> /boot/config.txt # https://github.com/raspberrypi/firmware/issues/1167 echo 'awb_auto_is_greyworld=1' >> /boot/config.txt echo 'Loading bcm2835 module' echo 'bcm2835-v4l2' > /etc/modules-load.d/picamera.conf echo "limiting journal log space" echo 'SystemMaxUse=250MB' >> /etc/systemd/journald.conf echo "generating locale" echo "en_GB.UTF-8 UTF-8" >> /etc/locale.gen locale-gen echo "disable bluetooth" echo 'dtoverlay=pi3-disable-bt' >> /boot/config.txt echo "Please reboot this PI now." } ## arg 1: the new package version ## arg 2: the old package version #pre_upgrade() { # do something here #} # arg 1: the new package version # arg 2: the old package version post_upgrade() { echo "changing the remote GIT source to BARE on node" cd /opt/ethoscope-device git remote set-url origin git://node/ethoscope.git #setting branch git checkout dev } # arg 1: the old package version pre_remove() { echo "disabling systemd service files" systemctl disable ethoscope_device.service ethoscope_listener.service ethoscope_update.service } ## arg 1: the old package version #post_remove() { # do something here #}