Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash -e
- #
- # pihole_flip.sh
- #
- # Convert Chromebook Flip (C100PA) to a PiHole Server
- # Script put together by /u/kurmudgeon
- #
- #####################################################################################################################
- # DISCLAIMER #
- #####################################################################################################################
- # THIS SCRIPT (AND STEPS OUTLINED) WILL REPLACE CHROME OS ON THE C100PA DEVICE'S EMMC WITH DEBIAN BUSTER (V10). #
- # THIS WILL VOID YOUR WARRANTY AND CAN CAUSE PERMANENT HARM TO THE DEVICE IF NOT DONE CORRECTLY, INCLUDING BRICKING #
- # THE DEVICE. USE THIS SCRIPT AT YOUR OWN RISK AS WELL AS ALL OTHER INFORMATION IN THIS DOCUMENT. #
- #####################################################################################################################
- ##############
- # References #
- ##############
- #
- # Removing write protect screw from motherboard:
- # https://gist.github.com/AliceGrey/41296c6d38955cdb882c73a470b26050
- #
- # See the InstallPrawnOS.sh from here (used as a reference only; this script is based on this one):
- # https://github.com/SolidHal/PrawnOS/tree/master/scripts/InstallScripts
- #
- # For info on Chrome OS Binary Flags:
- # https://chromium.googlesource.com/chromiumos/docs/+/master/firmware_test_manual.md#Update-GBB-Flags-AKA-extend-recovery-screen-timeout
- #
- # Changing boot flags:
- # https://www.reddit.com/r/chromeos/comments/23ql6x/how_make_the_developer_mode_screen_last_for_only/
- #
- #################
- # Prerequisites #
- #################
- #
- # First, enable developer mode on the Chromebook, booting unsigned media and booting from USB:
- # Note: enabling developer mode WILL ERASE ALL LOCALLY STORED DATA.
- #
- # 1. Shut down the Chromebook
- #
- # 2. Follow the post above for removing write-protection from the Chromebook BIOS, then reassemble the device and plug it in.
- #
- # 3. While powered off, hold the ESC and REFRESH buttons, then while holding them, press and release the POWER button.
- #
- # 4. You shoud now see a screen that says "Chrome OS is missing or damaged. Please insert a recovery USB stick or SD card."
- # - Press CTRL-D to continue
- #
- # 5. Next, you will see a screen that says, "To turn OS verification OFF, press ENTER. Your system will reboot and local data
- # will be cleared. To go back, press ESC."
- # - Press ENTER
- #
- # 6. You'll then see a screen that says "OS verification is OFF"
- # - Press CTRL-D to continue
- #
- # 7. Your device will now transition to developer mode. This process will take some time.
- #
- # 8. When you return to the "OS verification is OFF" screen, press CTRL-D to continue.
- #
- # 9. Your chromebook should now show the "Welcome!"" screen. There is a new option to "Enable debugging features", however, this
- # won't work.
- #
- # 10. Instead, press CTRL-ALT-REFRESH to display a console screen.
- #
- # 11. Login as 'root' (there is no password)
- #
- # 12. Run the following commands:
- #
- # - Modify boot screen with dev options:
- # flashrom --wp-disable
- #
- # - Next, rebuild bios with the following dev options (math for reference to show where 489 flag comes from):
- # GBB_FLAG_DEV_SCREEN_SHORT_DELAY 0x00000001
- # GBB_FLAG_FORCE_DEV_SWITCH_ON 0x00000008
- # GBB_FLAG_FORCE_DEV_BOOT_LEGACY 0x00000080
- # GBB_FLAG_DEFAULT_DEV_BOOT_LEGACY 0x00000400
- # -------------------------------------------
- # 0x00000489 = 0x489
- #
- # Commands:
- #
- # cd /root/
- # mkdir temp && cd temp
- # flashrom -r bios.bin
- # gbb_utility --set --flags=0x489 bios.bin custom_bios.bin
- # flashrom -w custom_bios.bin
- #
- # - To enable booting unsigned media:
- # crossystem dev_boot_signed_only=0
- #
- # - To enable booting from USB:
- # crossystem dev_boot_usb=1
- #
- # 13. Finally, type the following to shutdown your Chromebook:
- # shutdown now
- #
- # 14. From a Windows PC, download either the console or LXDE image from here (this guide is based on the console version):
- #
- # https://www.zutshigroup.com/doku.php/tech:c100p:main
- #
- # 15. Use BalenaEtcher to write the image to SDCard:
- #
- # https://www.balena.io/etcher/
- #
- # 16. Plug the SDCard into the Chromebook
- #
- # 17. Power on the Chromebook
- #
- # 18. At the "OS verification is OFF" screen, press CTRL-U (quickly, since we reduced the timer to 2 seconds).
- #
- # 19. You should now be at a login screen for the Debian instance on your SDCard.
- #
- # 20. Log in with the following credentials:
- # - User: debian-user
- # - Pass: debian-user
- #
- # 21. Now switch to the root user (no password for root initially) with the following command:
- # sudo su
- #
- # 22. Temporarily connect to WiFi (Follow the prompts and provide details as needed to connect to your WPA2 / 802.11 N/AC network):
- # /root/wifi.sh
- #
- # 23. Execute this script to migrate the Debian instance from your SDCard to the internal EMMC drive of your Chromebook, replacing Chrome OS completely.
- # chmod +x pihole_flip.sh
- # ./pihole_flip.sh
- #
- # Notes:
- #
- # - The following is an example command to copy a script to the local folder from a remote SMB share (see below for help with SCP
- # and certificates):
- #
- # cd /root/
- # scp -P 24 [email protected]:SHARE_NAME/pihole_flip.sh ./
- #
- # - If you have issues using scp due to certificates, update certificate cache:
- #
- # update-ca-certificates --fresh
- #
- # Install prerequisites
- apt update
- apt install -y gdisk cgpt rsync
- # Store boot device
- BOOT_DEVICE=$(mount | head -n 1 | cut -d '2' -f 1);
- # Store target device
- TARGET=$(ls /dev/mmcblk* | grep -F boot0 | sed "s/boot0//")p;
- # Cut off the "p" if we are using an sd card or internal emmc, doesn't change TARGET if we are using usb
- TARGET_NO_P=$(echo $TARGET | cut -d 'p' -f 1)
- if [ ! -e $TARGET_NO_P ];
- then
- echo "${TARGET_NO_P} does not exist, have you plugged in your target sd card or usb device?"
- exit 1
- fi
- # Force targeting EMMC drive
- TARGET_EMMC=true;
- # Setup partition map for external bootable device, aka usb or sd card
- external_partition() {
- EXTERNAL_TARGET=$1
- kernel_start=8192
- kernel_size=65536
- # Wipe the partition map, cgpt doesn't like anything weird in the primary or backup partition maps
- sgdisk -Z $EXTERNAL_TARGET
- partprobe $EXTERNAL_TARGET
- # Make the base gpt partition map
- parted --script $EXTERNAL_TARGET mklabel gpt
- cgpt create $EXTERNAL_TARGET
- # Must use cgpt to make the kernel partition, as we need the -S, -T, and -P variables
- cgpt add -i 1 -t kernel -b $kernel_start -s $kernel_size -l Kernel -S 1 -T 5 -P 10 $EXTERNAL_TARGET
- # Now the main filesystem
- # cgpt doesn't seem to handle this part correctly
- sgdisk -N 2 $EXTERNAL_TARGET
- # Set the type to "data"
- sgdisk -t 2:0700 $EXTERNAL_TARGET
- # Name it "properly" - Probably not required, but looks nice
- sgdisk -c 2:Root $EXTERNAL_TARGET
- # Reload the partition mapping
- partprobe $EXTERNAL_TARGET
- }
- # Setup partition map on internal EMMC drive
- emmc_partition() {
- # Disable dmesg, writing the partition map tries to write the the first gpt table, which is unmodifiable
- dmesg -D
- echo Writing partition map to internal emmc
- DISK_SZ="$(blockdev --getsz /dev/mmcblk2)"
- echo Total disk size is: $DISK_SZ
- if [ $DISK_SZ = 30785536 ]
- then
- echo Detected Emmc Type 1
- sfdisk /dev/mmcblk2 < $RESOURCES/mmc.partmap || true
- elif [ $DISK_SZ = 30777344 ]
- then
- echo Detected Emmc Type 2
- sfdisk /dev/mmcblk2 < $RESOURCES/mmc_type2.partmap || true
- else
- echo ERROR! Not a known EMMC type, please open an issue on github or send SolidHal an email with the Total disk size reported above
- echo Try a fallback value? This will allow installation to continue, at the cost of a very small amount of disk space. This may not work.
- select yn in "Yes" "No"
- do
- case $yn,$REPLY in
- Yes,*|*,Yes )
- echo Trying Emmc Type 2
- sfdisk /dev/mmcblk2 < $RESOURCES/mmc_type2.partmap || true
- break
- ;;
- * )
- echo "Invalid Option, please enter Yes or No, 1 or 2"
- ;;
- esac
- done
- fi
- dmesg -E
- }
- # Only try to unmount if the device is mounted
- # If it is, try anyway, the dd will (likely) take care of it anyway
- if findmnt ${TARGET}1 > /dev/null
- then
- umount ${TARGET}1 || /bin/true
- fi
- if findmnt ${TARGET}2 > /dev/null
- then
- umount ${TARGET}2 || /bin/true
- fi
- # Only use the emmc_partition function for "special cases", aka veyron devices (aka C100PA)
- if [[ $TARGET == "/dev/mmcblk2p" ]] && $TARGET_EMMC
- then
- emmc_partition
- else
- external_partition $TARGET_NO_P
- fi
- KERNEL_PARTITION=${TARGET}1
- ROOT_PARTITION=${TARGET}2
- echo Writing kernel to partition $KERNEL_PARTITION
- dd if=/dev/zero of=$KERNEL_PARTITION bs=512 count=65536
- dd if=${BOOT_DEVICE}1 of=$KERNEL_PARTITION
- echo Creating ext4 filesystem on root partition
- mkfs.ext4 -F -b 1024 $ROOT_PARTITION
- INSTALL_MOUNT=/mnt/install_mount
- mkdir -p $INSTALL_MOUNT/
- mount $ROOT_PARTITION $INSTALL_MOUNT/
- echo Syncing live root filesystem with new root filesystem, this will take about 4 minutes...
- rsync -ah --info=progress2 --info=name0 --numeric-ids -x / $INSTALL_MOUNT/
- # Remove the live-fstab and install a base fstab
- rm $INSTALL_MOUNT/etc/fstab
- echo "${ROOT_PARTITION} / ext4 defaults,noatime 0 1" > $INSTALL_MOUNT/etc/fstab
- # Unmount root
- umount $ROOT_PARTITION
- # Run file system check on root
- echo Running fsck
- e2fsck -p -f $ROOT_PARTITION
- # Done, reboot
- echo "Please remove the booted device after power off is complete"
- while true; do
- read -r -p "Reboot? [y/N]" re
- case $re in
- [Yy]* ) reboot;;
- [Nn]* ) exit;;
- * ) echo "Please answer y or n";;
- esac
- done
- ##########################################################################################
- # Congrats, you have now replaced Chrome OS on your Chromebook with Debian Buster (v10). #
- # Feel free to install updates, Debian packages, etc. #
- ##########################################################################################
- ######################################################################################################
- # THE FOLLOWING IS COMPLETELY OPTIONAL AND ARE HERE AS MY OWN PERSONAL NOTES FOR POST-INSTALL STEPS. #
- # ALL COMMANDS ASSUME YOU ARE RUNNING AS ROOT USER. #
- ######################################################################################################
- ########################################################################################################################
- # Connect to WiFi using cli (the wifi.sh script found in the Debian image doesn't survive reboots. This method will.) #
- ########################################################################################################################
- #
- # Run the following:
- # apt update && apt install -y wireless-tools
- #
- # List network status:
- # ip a
- #
- # List wireless network devices:
- # iw dev
- #
- # Turn on the wireless networking device (note, wlan0 is an example, use the one from the previous step for your device):
- # ip link set wlan0 up
- #
- # Scan for available networks (you can skip if you already know your WLAN SSID):
- # su -l
- # iwlist scan
- #
- # Edit wlan configs with your WLAN network settings:
- # nano /etc/network/interfaces
- #
- # Below is an example config:
- #
- # # My wifi device
- # allow-hotplug wlan0
- # iface wlan0 inet dhcp
- # wpa-ssid MY SSID
- # wpa-psk PASSWORD
- #
- # Now, connect to the WLAN:
- # ifup wlan0
- #
- # Verify the connection:
- # iw wlan0 link
- # ip a
- #
- ################
- # Disable IPv6 #
- ################
- #
- # Run the following:
- # nano /etc/sysctl.conf
- #
- # Add the following:
- #
- # # disable IPv6
- # net.ipv6.conf.all.disable_ipv6 = 1
- # net.ipv6.conf.default.disable_ipv6 = 1
- # net.ipv6.conf.lo.disable_ipv6 = 1
- #
- # Save and close the file.
- #
- # Run the following to reload sysctl config:
- #
- # sysctl -p
- #
- # Verify IPv6 is now disabled:
- #
- # ip a
- # ifconfig wlan0
- #
- ##############################################
- # Temporarily turn off WiFi power management #
- ##############################################
- #
- # View current power saving settings:
- # iw dev wlan0 get power_save
- #
- # Turn power-saving off:
- # iw dev wlan0 set power_save off
- #
- #####################################################################
- # Create systemd service to automatically disable WiFi power-saving #
- #####################################################################
- #
- # Add script:
- # nano /root/disable_wifi_powermanagement.sh
- #
- # Add the following to script:
- # #!/bin/sh
- #
- # iw dev wlan0 set power_save off
- #
- # Save changes and exit.
- #
- # Make the script executable:
- # chmod +x /root/disable_wifi_powermanagement.sh
- #
- # Create a service to trigger the script:
- # nano /etc/systemd/system/disable-wifi-powermanagement.service
- #
- # Add the following:
- # [Unit]
- # Description=Disables WiFi Power Management
- # After=network.target
- # After=network-online.target
- #
- # [Service]
- # Type=simple
- # ExecStart=/bin/sh /root/disable_wifi_powermanagement.sh
- #
- # [Install]
- # WantedBy=multi-user.target
- #
- # Save changes, change permissions:
- # chmod 644 /etc/systemd/system/disable-wifi-powermanagement.service
- # systemctl daemon-reload
- #
- # Start the service:
- # systemctl start /etc/systemd/system/disable-wifi-powermanagement.service
- #
- # Check if power-saving has been disabled:
- # iwconfig wlan0 | grep "Power Management:"
- #
- # Start service at automatically:
- # systemctl enable /etc/systemd/system/disable-wifi-powermanagement.service
- #
- ###############
- # Install SSH #
- ###############
- #
- # Run the following
- # apt update && apt install -y openssh-client openssh-server
- #
- # Configure SSH
- # nano /etc/ssh/sshd_config
- #
- # Change the following (set the port to your preference):
- #
- # Port 55555
- # PermitRootLogin yes
- #
- # Save changes, then restart SSH:
- # systemctl restart ssh
- #
- #######################
- # Configure Time Zone #
- #######################
- #
- # timedatectl set-timezone America/Chicago
- #
- #################################
- # Configure Time Sync w/ Google #
- #################################
- #
- # Run the following:
- # apt purge ntp
- # nano /etc/systemd/timesyncd.conf
- #
- # Paste the following:
- # [Time]
- # NTP=time.google.com
- #
- # Run the following:
- # timedatectl set-ntp true
- # timedatectl status
- # timedatectl timesync-status
- #
- #######################################################
- # Prevent device from powering off when lid is closed #
- #######################################################
- #
- # Run the following:
- # nano /etc/systemd/logind.conf
- #
- # Find and set the following line:
- #
- # HandleLidSwitch=ignore
- #
- # Save changes.
- #
- # Restart the login service:
- # service systemd-logind restart
- #
- #######################################################################
- # Have the screen automatically turn off after 1 minute of inactivity #
- #######################################################################
- #
- # Run the following:
- # nano /etc/systemd/system/enable-console-blanking.service
- #
- # Add the following to the file:
- # [Unit]
- # Description=Enable virtual console blanking
- #
- # [Service]
- # Type=oneshot
- # Environment=TERM=linux
- # StandardOutput=tty
- # TTYPath=/dev/console
- # ExecStart=/usr/bin/setterm -blank 1
- #
- # [Install]
- # WantedBy=multi-user.target
- #
- # Set permissions:
- # chmod 664 /etc/systemd/system/enable-console-blanking.service
- # systemctl daemon-reload
- #
- # Enable the new service:
- # systemctl start enable-console-blanking.service
- #
- # Automatically run new service at boot:
- # systemctl enable enable-console-blanking.service
- #
- # Reboot the machine.
- # reboot
- #
- #############################################################
- # Update certificate cache (so SSH, SCP and curl will work) #
- #############################################################
- #
- # Run the following:
- # update-ca-certificates --fresh
- #
- ################################################################
- # Configure locale (remove/prevent unwanted localization data) #
- ################################################################
- #
- # Run the following:
- # dpkg-reconfigure locales
- # apt update && apt install -y localepurge
- #
- ##################################
- # Set CPU scaling to performance #
- ##################################
- #
- # Create script to change scaling:
- # nano /root/set_scaling_to_performance.sh
- #
- # Add the following to the file:
- # #!/bin/sh
- # echo performance > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
- # echo performance > /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor
- # echo performance > /sys/devices/system/cpu/cpu2/cpufreq/scaling_governor
- # echo performance > /sys/devices/system/cpu/cpu3/cpufreq/scaling_governor
- #
- # Save the file and make it executable:
- # chmod +x /root/set_scaling_to_performance.sh
- #
- # Create a service to call the script:
- # nano /etc/systemd/system/set-cpu-scaling.service
- #
- # Add the following to the file:
- # [Unit]
- # Description=Sets CPU scaling to Performance
- #
- # [Service]
- # Type=simple
- # ExecStart=/bin/sh /root/set_scaling_to_performance.sh
- #
- # [Install]
- # WantedBy=multi-user.target
- #
- # Now run:
- # chmod 664 /etc/systemd/system/set-cpu-scaling.service
- # systemctl daemon-reload
- #
- # Start the service:
- # systemctl start set-cpu-scaling.service
- #
- # Verify governor now set to "Performance":
- #
- # cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
- #
- # Run the service automatically at boot:
- # systemctl enable set-cpu-scaling.service
- #
- ##########################
- # Disable soundcard/ALSA #
- ##########################
- #
- # Run the following:
- # nano /etc/modprobe.d/sound.blacklist.conf
- #
- # Add the following to the file:
- # blacklist snd_soc_rockchip_max98090
- #
- # Save changes and exit.
- #
- # Now run:
- # mkdir /etc/modprobe.d/disabled && mv /etc/modprobe.d/alsa.conf disabled/
- #
- #########################################
- # Install Unbound (Reverse DNS Service) #
- #########################################
- #
- # Run the following:
- # apt update && apt install -y unbound
- #
- # Get newest root hints:
- # wget https://www.internic.net/domain/named.root -qO- | tee /var/lib/unbound/root.hints
- #
- # Configure unbound as needed:
- # nano /etc/unbound/unbound.conf.d/pihole-flip.conf
- #
- # Restart unbound service:
- # service unbound restart
- #
- #############################################
- # Install RpiMonitor (Raspberry Pi Monitor) #
- #############################################
- #
- # Run the following:
- # apt update && apt install -y dirmngr
- #
- # apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 2C0D3C0F
- #
- # echo "deb https://www.giteduberger.fr rpimonitor/" > /etc/apt/sources.list.d/rpimonitor.list
- #
- # apt update && apt install -y rpimonitor
- #
- # /etc/init.d/rpimonitor update
- #
- #######################################################
- # Adjust RpiMonitor templates for Chromebook Hardware #
- #######################################################
- #
- # Edit main template that chooses which templates to load:
- # nano /etc/rpimonitor/template/raspbian.conf
- #
- # Make the following changes:
- #
- # include=/etc/rpimonitor/template/version.conf
- # include=/etc/rpimonitor/template/uptime.conf
- # include=/etc/rpimonitor/template/cpu.conf
- # include=/etc/rpimonitor/template/temperature.conf
- # include=/etc/rpimonitor/template/memory.conf
- # #include=/etc/rpimonitor/template/swap.conf
- # #include=/etc/rpimonitor/template/sdcard.conf
- # #include=/etc/rpimonitor/template/network.conf
- #
- # #include=/etc/rpimonitor/template/printer.conf
- # include=/etc/rpimonitor/template/storage.conf
- # include=/etc/rpimonitor/template/services.conf
- # include=/etc/rpimonitor/template/wlan.conf
- # #include=/etc/rpimonitor/template/dht11.conf
- # #include=/etc/rpimonitor/template/entropy.conf
- #
- # Edit version file to remove unneeded field:
- # nano /etc/rpimonitor/template/version.conf
- #
- # Make the following changes:
- #
- # #web.status.1.content.1.line.4='Firmware: <b>' + data.firmware + '</b>'
- # web.status.1.content.1.line.4='Package(s): <b>' + data.upgrade + '</b>' + ShowInfo('packages','Package(s) upgradable(s)',data.packages)
- #
- # Edit the CPU file to adjust for the Chromebook Flip
- # nano /etc/rpimonitor/template/cpu.conf
- #
- # Make the following changes to remove voltage readings since that won't work for Rockchip:
- #
- # #dynamic.2.name=cpu_voltage
- # #dynamic.2.source=vcgencmd measure_volts core
- # #dynamic.2.regexp=(\d+.\d+)V
- # #dynamic.2.postprocess=
- # #dynamic.2.rrd=
- #
- # Edit the Temperature file to adjust for Chromebook Flip/Rockchip:
- # nano /etc/rpimonitor/template/temperature.conf
- #
- # Make the following changes:
- #
- # dynamic.12.source=/sys/devices/virtual/thermal/thermal_zone1/temp
- #
- # #web.status.1.content.4.line.1="CPU Temperature: <b>"+data.soc_temp+"°C</b>"
- # web.status.1.content.4.line.1=JustGageBar("CPU Temperature", data.soc_temp+"°C", 20, data.soc_temp, 85, 100, 80, ["#28a745","#ffc107","#dc3545"], 50, 70)
- # #web.status.1.content.4.line.1=JustGageBar("Temperature", "°C", 40, data.soc_temp, 80, 100, 80)
- #
- # Edit the storage template to use the internal EMMC drive:
- # nano /etc/rpimonitor/template/storage.conf
- #
- # Make the following changes
- #
- # static.10.name=storage1_total
- # static.10.source=df -t ext4
- # static.10.regexp=/dev/root\s+(\d+)
- # static.10.postprocess=$1/1024
- #
- # #static.11.name=storage2_total
- # #static.11.source=df -t ext4
- # #static.11.regexp=sda3\s+(\d+)
- # #static.11.postprocess=$1/1024
- #
- # dynamic.14.name=storage1_used
- # dynamic.14.source=df -t ext4
- # dynamic.14.regexp=/dev/root\s+\d+\s+(\d+)
- # dynamic.14.postprocess=$1/1024
- # dynamic.14.rrd=GAUGE
- #
- # #dynamic.15.name=storage2_used
- # #dynamic.15.source=df -t ext4
- # #dynamic.15.regexp=sda3\s+\d+\s+(\d+)
- # #dynamic.15.postprocess=$1/1024
- # #dynamic.15.rrd=GAUGE
- #
- # web.status.1.content.9.name=Storage
- # web.status.1.content.9.icon=usb_hdd.png
- # web.status.1.content.9.line.1="<b>/</b> Used: <b>"+KMG(data.storage1_used,'M')+"</b> (<b>"+Percent(data.storage1_used,data.storage1_total,'M')+"</b>) Free: <b>"+KMG(data.storage1_total-data.storage1_used,'M')+ "</b> Total: <b>"+ KMG(data.storage1_total,$web.status.1.content.9.line.2=ProgressBar(data.storage1_used,data.storage1_total)
- # #web.status.1.content.9.line.3="<b>/storage2</b> Used: <b>"+KMG(data.storage2_used,'M')+"</b> (<b>"+Percent(data.storage2_used,data.storage2_total,'M')+"</b>) Free: <b>"+KMG(data.storage2_total-data.storage2_used,'M')+ "</b> Total: <b>"+ KMG(data.storag$#web.status.1.content.9.line.4=ProgressBar(data.storage2_used,data.storage2_total)
- #
- # web.statistics.1.content.9.name=Storage
- # web.statistics.1.content.9.graph.1=storage1_total
- # web.statistics.1.content.9.graph.2=storage1_used
- # web.statistics.1.content.9.ds_graph_options.storage1_total.label=EMMC total space (MB)
- # web.statistics.1.content.9.ds_graph_options.storage1_total.color="#FF7777"
- # web.statistics.1.content.9.ds_graph_options.storage1_used.label=EMMC used space (MB)
- # web.statistics.1.content.9.ds_graph_options.storage1_used.lines={ fill: true }
- # web.statistics.1.content.9.ds_graph_options.storage1_used.color="#7777FF"
- #
- # #web.statistics.1.content.10.name=Storage2
- # #web.statistics.1.content.10.graph.1=storage2_total
- # #web.statistics.1.content.10.graph.2=storage2_used
- # #web.statistics.1.content.10.ds_graph_options.storage2_total.label=Storage2 total space (MB)
- # #web.statistics.1.content.10.ds_graph_options.storage2_total.color="#FF7777"
- # #web.statistics.1.content.10.ds_graph_options.storage2_used.label=Storage2 used space (MB)
- # #web.statistics.1.content.10.ds_graph_options.storage2_used.lines={ fill: true }
- # #web.statistics.1.content.10.ds_graph_options.storage2_used.color="#7777FF"
- #
- # Edit the WiFi template:
- # nano /etc/rpimonitor/wlan.conf
- #
- # Make the following changes:
- #
- # dynamic.18.name=wifi_received
- # dynamic.18.source=/sys/class/net/wlan0/statistics/rx_bytes
- # dynamic.18.regexp=(.*)
- # dynamic.18.postprocess=$1*-1
- # dynamic.18.rrd=DERIVE
- # dynamic.18.max=0
- #
- # dynamic.19.name=wifi_send
- # dynamic.19.source=/sys/class/net/wlan0/statistics/tx_bytes
- # dynamic.19.regexp=(.*)
- # dynamic.19.postprocess=
- # dynamic.19.rrd=DERIVE
- # dynamic.19.min=0
- #
- # dynamic.20.name=ssid
- # dynamic.20.source=iw wlan0 info | grep ssid | cut -c 7-
- # dynamic.20.regexp=(.*)
- #
- # dynamic.21.name=channel
- # dynamic.21.source=iw wlan0 info | grep "channel"
- # dynamic.21.regexp=(.*)
- #
- # dynamic.22.name=mac
- # dynamic.22.source=iw wlan0 info | grep addr | cut -c 7- | tr a-z A-Z
- # dynamic.22.regexp=(.*)
- #
- # dynamic.23.name=linkspeed
- # dynamic.23.source=iw dev wlan0 link | grep rx | cut -c 14-
- # dynamic.23.regexp=(.*)
- #
- # dynamic.24.name=powermanagement
- # dynamic.24.source=iwconfig wlan0 | grep "Power Management:" | cut -c 28-
- # dynamic.24.regexp=(.*)
- #
- # web.status.1.content.9.name=WiFi
- # web.status.1.content.9.icon=wifi.png
- # web.status.1.content.9.line.1="SSID: <b>"+data.ssid+"</b>"
- # web.status.1.content.9.line.2="Sent: <b>"+KMG(data.wifi_send)+"<i class='icon-arrow-up'></i></b> Received: <b>"+KMG(Math.abs(data.wifi_received)) + "<i class='icon-arrow-down'></i></b>"
- # web.status.1.content.9.line.3="Link Speed: <b>"+data.linkspeed+"</b>"
- # web.status.1.content.9.line.4="Connection: "+data.channel
- # web.status.1.content.9.line.5="Power Management: <b>"+data.powermanagement+"</b>"
- # web.status.1.content.9.line.6="MAC: <b>"+data.mac+"</b>"
- #
- # web.statistics.1.content.9.name=WiFi
- # web.statistics.1.content.9.graph.1=wifi_send
- # web.statistics.1.content.9.graph.2=wifi_received
- # web.statistics.1.content.9.graph_options.yaxis={ tickFormatter: function (v) { if (Math.abs(v) > 1048576) return (Math.round(v*10/1024/1024)/10) + " MiB/s" ; if (Math.abs(v) > 1024) return (Math.round(v*10/1024)/10) + " KiB/s" ; else return v + " B/s" }, }
- # web.statistics.1.content.9.ds_graph_options.wifi_send.label=Upload bandwidth (bits)
- # web.statistics.1.content.9.ds_graph_options.wifi_send.lines={ fill: true }
- # web.statistics.1.content.9.ds_graph_options.wifi_send.color="#FF7777"
- # web.statistics.1.content.9.ds_graph_options.wifi_received.label=Download bandwidth (bits)
- # web.statistics.1.content.9.ds_graph_options.wifi_received.lines={ fill: true }
- # web.statistics.1.content.9.ds_graph_options.wifi_received.color="#77FF77"
- #
- # Edit the services template to monitor services on the device:
- # nano /etc/rpimonitor/services.conf
- #
- # Make the following changes:
- #
- # dynamic.1.name=ssh
- # dynamic.1.source=netstat -nlt
- # dynamic.1.regexp=tcp .*:(55555).*LISTEN
- #
- # dynamic.2.name=rpimonitor
- # dynamic.2.source=netstat -nlt
- # dynamic.2.regexp=tcp .*:(8888).*LISTEN
- #
- # dynamic.3.name=http
- # dynamic.3.source=netstat -nlt
- # dynamic.3.regexp=tcp .*:(80).*LISTEN
- #
- # dynamic.4.name=unbound
- # dynamic.4.source=netstat -nlt
- # dynamic.4.regexp=tcp .*:(5335).*LISTEN
- #
- # dynamic.5.name=dns
- # dynamic.5.source=netstat -nlt
- # dynamic.5.regexp=tcp .*:(53).*LISTEN
- #
- # dynamic.6.name=pihole
- # dynamic.6.source=netstat -nlt
- # dynamic.6.regexp=tcp .*:(4711).*LISTEN
- #
- # #dynamic.4.name=https
- # #dynamic.4.source=netstat -nlt
- # #dynamic.4.regexp=tcp .*:(443).*LISTEN
- #
- # #dynamic.5.name=mysql
- # #dynamic.5.source=netstat -nlt
- # #dynamic.5.regexp=tcp .*:(3306).*LISTEN
- #
- # web.status.1.content.1.name=Services
- # web.status.1.content.1.icon=daemons.png
- # #web.status.1.content.1.line.1="<b>ssh</b> : "+Label(data.ssh,"==22","OK","success")+Label(data.ssh,"!=22","KO","danger")+" <b>rpimonitor</b> : "+Label(data.rpimonitor,"==8888","OK","success")+Label(data.rpimonitor,"!=8888","KO","danger")+" <b>nginx http</b> : "+Label(data.http,"==80","OK","success")+Label(data.http,"!=80","KO","danger")+" <b>nginx https</b> : "+Label(data.https,"==443","OK","success")+Label(data.https,"!=443","KO","danger")+" <b>mysql</b> : "+Label(data.mysql,"==3306","OK","success")+Label(data.mysql,"!=3306","KO","danger")
- # web.status.1.content.1.line.1=Label(data.ssh,"==55555","ssh","success")+Label(data.ssh,"!=55555","ssh","danger")+" "+Label(data.rpimonitor,"==8888","rpimonitor","success")+Label(data.rpimonitor,"!=8888","rpimonitor","danger")+" "+Label(data.http,"==80","nginx","success")+Label(data.http,"!=80","nginx","danger")+" "+Label(data.unbound,"==5335","unbound","success")+Label(data.unbound,"!=5335","unbound","danger")+" "+Label(data.dns,"==53","dns","success")+Label(data.dns,"!=53","dns","danger")+" "+Label(data.pihole,"==4711","pihole-FTL","success")+Label(data.pihole,"!=4711","pihole-FTL","danger")
- #
- # Now, restart the RpiMonitor service and log into it to see the changes.
- # service rpimonitor restart
- #
- # Note: pihole-FTL will be red until after the next portion of this is completed.
- #
- ###################
- # Install Pi-Hole #
- ###################
- #
- # Run the following:
- # apt update && apt install -y curl
- # curl -sSL https://install.pi-hole.net | bash
- #
- # Change Pi-Hole Password:
- # pihole -a -p
- #
- ##################################################
- # Find PiHole temp settings file (for reference) #
- ##################################################
- #
- # Run the follosing:
- # grep -rnw /var/www/html -e 'temp'
- #
- # Edit Pi-Hole for Chromebook Flip Hardware Temp Readings:
- # nano /var/www/html/admin/scripts/pi-hole/php/header.php
- #
- # Make the following adjustments:
- #
- # // Try to get temperature value from different places (OS dependent)
- #
- # // Chromebook Flip
- # if (file_exists("/sys/devices/virtual/thermal/thermal_zone1/temp"))
- # {
- # $output = rtrim(file_get_contents("/sys/devices/virtual/thermal/thermal_zone1/temp"));
- # }
- # else
- # {
- # if(file_exists("/sys/class/thermal/thermal_zone0/temp"))
- # {
- # $output = rtrim(file_get_contents("/sys/class/thermal/thermal_zone0/temp"));
- # }
- # elseif (file_exists("/sys/class/hwmon/hwmon0/temp1_input"))
- # {
- # $output = rtrim(file_get_contents("/sys/class/hwmon/hwmon0/temp1_input"));
- # }
- # else
- # {
- # $output = "";
- # }
- # }
- #
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement