Advertisement
Guest User

Convert Chromebook Flip (C100PA) to a PiHole Server

a guest
Aug 7th, 2021
1,027
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 31.36 KB | None | 0 0
  1. #!/bin/bash -e
  2. #
  3. # pihole_flip.sh
  4. #
  5. # Convert Chromebook Flip (C100PA) to a PiHole Server
  6. # Script put together by /u/kurmudgeon
  7. #
  8.  
  9.  
  10. #####################################################################################################################
  11. # DISCLAIMER                                                                                                        #
  12. #####################################################################################################################
  13. # THIS SCRIPT (AND STEPS OUTLINED) WILL REPLACE CHROME OS ON THE C100PA DEVICE'S EMMC WITH DEBIAN BUSTER (V10).     #
  14. # THIS WILL VOID YOUR WARRANTY AND CAN CAUSE PERMANENT HARM TO THE DEVICE IF NOT DONE CORRECTLY, INCLUDING BRICKING #
  15. # THE DEVICE. USE THIS SCRIPT AT YOUR OWN RISK AS WELL AS ALL OTHER INFORMATION IN THIS DOCUMENT.                   #
  16. #####################################################################################################################
  17.  
  18.  
  19. ##############
  20. # References #
  21. ##############
  22. #
  23. # Removing write protect screw from motherboard:
  24. #     https://gist.github.com/AliceGrey/41296c6d38955cdb882c73a470b26050
  25. #
  26. # See the InstallPrawnOS.sh from here (used as a reference only; this script is based on this one):
  27. #     https://github.com/SolidHal/PrawnOS/tree/master/scripts/InstallScripts
  28. #
  29. # For info on Chrome OS Binary Flags:
  30. #     https://chromium.googlesource.com/chromiumos/docs/+/master/firmware_test_manual.md#Update-GBB-Flags-AKA-extend-recovery-screen-timeout
  31. #
  32. # Changing boot flags:
  33. #     https://www.reddit.com/r/chromeos/comments/23ql6x/how_make_the_developer_mode_screen_last_for_only/
  34. #
  35.  
  36.  
  37. #################
  38. # Prerequisites #
  39. #################
  40. #
  41. # First, enable developer mode on the Chromebook, booting unsigned media and booting from USB:
  42. # Note: enabling developer mode WILL ERASE ALL LOCALLY STORED DATA.
  43. #
  44. # 1. Shut down the Chromebook
  45. #
  46. # 2. Follow the post above for removing write-protection from the Chromebook BIOS, then reassemble the device and plug it in.
  47. #
  48. # 3. While powered off, hold the ESC and REFRESH buttons, then while holding them, press and release the POWER button.
  49. #
  50. # 4. You shoud now see a screen that says "Chrome OS is missing or damaged. Please insert a recovery USB stick or SD card."
  51. #    - Press CTRL-D to continue
  52. #
  53. # 5. Next, you will see a screen that says, "To turn OS verification OFF, press ENTER. Your system will reboot and local data
  54. #    will be cleared. To go back, press ESC."
  55. #    - Press ENTER
  56. #
  57. # 6. You'll then see a screen that says "OS verification is OFF"
  58. #    - Press CTRL-D to continue
  59. #
  60. # 7. Your device will now transition to developer mode.  This process will take some time.
  61. #
  62. # 8. When you return to the "OS verification is OFF" screen, press CTRL-D to continue.
  63. #
  64. # 9. Your chromebook should now show the "Welcome!"" screen. There is a new option to "Enable debugging features", however, this
  65. #    won't work.
  66. #
  67. # 10. Instead, press CTRL-ALT-REFRESH to display a console screen.
  68. #
  69. # 11. Login as 'root' (there is no password)
  70. #
  71. # 12. Run the following commands:
  72. #
  73. #    - Modify boot screen with dev options:
  74. #        flashrom --wp-disable
  75. #
  76. #    - Next, rebuild bios with the following dev options (math for reference to show where 489 flag comes from):
  77. #      GBB_FLAG_DEV_SCREEN_SHORT_DELAY  0x00000001
  78. #      GBB_FLAG_FORCE_DEV_SWITCH_ON     0x00000008
  79. #      GBB_FLAG_FORCE_DEV_BOOT_LEGACY   0x00000080
  80. #      GBB_FLAG_DEFAULT_DEV_BOOT_LEGACY 0x00000400
  81. #      -------------------------------------------
  82. #                                       0x00000489 = 0x489
  83. #
  84. #      Commands:
  85. #
  86. #        cd /root/
  87. #        mkdir temp && cd temp
  88. #        flashrom -r bios.bin
  89. #        gbb_utility --set --flags=0x489 bios.bin custom_bios.bin
  90. #        flashrom -w custom_bios.bin
  91. #
  92. #    - To enable booting unsigned media:
  93. #        crossystem dev_boot_signed_only=0
  94. #
  95. #    - To enable booting from USB:
  96. #        crossystem dev_boot_usb=1
  97. #
  98. # 13. Finally, type the following to shutdown your Chromebook:
  99. #    shutdown now
  100. #
  101. # 14. From a Windows PC, download either the console or LXDE image from here (this guide is based on the console version):
  102. #
  103. #    https://www.zutshigroup.com/doku.php/tech:c100p:main
  104. #
  105. # 15. Use BalenaEtcher to write the image to SDCard:
  106. #
  107. #    https://www.balena.io/etcher/
  108. #
  109. # 16. Plug the SDCard into the Chromebook
  110. #
  111. # 17. Power on the Chromebook
  112. #
  113. # 18. At the "OS verification is OFF" screen, press CTRL-U (quickly, since we reduced the timer to 2 seconds).
  114. #
  115. # 19. You should now be at a login screen for the Debian instance on your SDCard.
  116. #
  117. # 20. Log in with the following credentials:
  118. #    - User: debian-user
  119. #    - Pass: debian-user
  120. #
  121. # 21. Now switch to the root user (no password for root initially) with the following command:
  122. #    sudo su
  123. #
  124. # 22. Temporarily connect to WiFi (Follow the prompts and provide details as needed to connect to your WPA2 / 802.11 N/AC network):
  125. #    /root/wifi.sh
  126. #
  127. # 23. Execute this script to migrate the Debian instance from your SDCard to the internal EMMC drive of your Chromebook, replacing Chrome OS completely.
  128. #    chmod +x pihole_flip.sh
  129. #    ./pihole_flip.sh
  130. #
  131. # Notes:
  132. #
  133. # - 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
  134. #   and certificates):
  135. #
  136. #    cd /root/
  137. #    scp -P 24 [email protected]:SHARE_NAME/pihole_flip.sh ./
  138. #
  139. # - If you have issues using scp due to certificates, update certificate cache:
  140. #
  141. #    update-ca-certificates --fresh
  142. #
  143.  
  144.  
  145. # Install prerequisites
  146. apt update
  147. apt install -y gdisk cgpt rsync
  148.  
  149. # Store boot device
  150. BOOT_DEVICE=$(mount | head -n 1 | cut -d '2' -f 1);
  151.  
  152. # Store target device
  153. TARGET=$(ls /dev/mmcblk* | grep -F boot0 | sed "s/boot0//")p;
  154.  
  155. # Cut off the "p" if we are using an sd card or internal emmc, doesn't change TARGET if we are using usb
  156. TARGET_NO_P=$(echo $TARGET | cut -d 'p' -f 1)
  157. if [ ! -e $TARGET_NO_P ];
  158. then
  159.     echo "${TARGET_NO_P} does not exist, have you plugged in your target sd card or usb device?"
  160.     exit 1
  161. fi
  162.  
  163. # Force targeting EMMC drive
  164. TARGET_EMMC=true;
  165.  
  166. # Setup partition map for external bootable device, aka usb or sd card
  167. external_partition() {
  168.  
  169.     EXTERNAL_TARGET=$1
  170.     kernel_start=8192
  171.     kernel_size=65536
  172.  
  173.     # Wipe the partition map, cgpt doesn't like anything weird in the primary or backup partition maps
  174.     sgdisk -Z $EXTERNAL_TARGET
  175.     partprobe $EXTERNAL_TARGET
  176.  
  177.     # Make the base gpt partition map
  178.     parted --script $EXTERNAL_TARGET mklabel gpt
  179.     cgpt create $EXTERNAL_TARGET
  180.    
  181.     # Must use cgpt to make the kernel partition, as we need the -S, -T, and -P variables
  182.     cgpt add -i 1 -t kernel -b $kernel_start -s $kernel_size -l Kernel -S 1 -T 5 -P 10 $EXTERNAL_TARGET
  183.    
  184.     # Now the main filesystem
  185.     # cgpt doesn't seem to handle this part correctly
  186.     sgdisk -N 2 $EXTERNAL_TARGET
  187.    
  188.     # Set the type to "data"
  189.     sgdisk -t 2:0700 $EXTERNAL_TARGET
  190.    
  191.     # Name it "properly" - Probably not required, but looks nice
  192.     sgdisk -c 2:Root $EXTERNAL_TARGET
  193.    
  194.     # Reload the partition mapping
  195.     partprobe $EXTERNAL_TARGET
  196.  
  197. }
  198.  
  199. # Setup partition map on internal EMMC drive
  200. emmc_partition() {
  201.  
  202.     # Disable dmesg, writing the partition map tries to write the the first gpt table, which is unmodifiable
  203.     dmesg -D
  204.    
  205.     echo Writing partition map to internal emmc
  206.     DISK_SZ="$(blockdev --getsz /dev/mmcblk2)"
  207.     echo Total disk size is: $DISK_SZ
  208.    
  209.     if [ $DISK_SZ = 30785536 ]
  210.     then
  211.         echo Detected Emmc Type 1
  212.         sfdisk /dev/mmcblk2 < $RESOURCES/mmc.partmap || true
  213.  
  214.     elif [ $DISK_SZ = 30777344 ]
  215.     then
  216.         echo Detected Emmc Type 2
  217.         sfdisk /dev/mmcblk2 < $RESOURCES/mmc_type2.partmap || true
  218.     else
  219.         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
  220.         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.
  221.         select yn in "Yes" "No"
  222.         do
  223.             case $yn,$REPLY in
  224.                 Yes,*|*,Yes )
  225.                     echo Trying Emmc Type 2
  226.                     sfdisk /dev/mmcblk2 < $RESOURCES/mmc_type2.partmap || true
  227.                     break
  228.                     ;;
  229.                 * )
  230.                     echo "Invalid Option, please enter Yes or No, 1 or 2"
  231.                     ;;
  232.             esac
  233.         done
  234.     fi
  235.  
  236.     dmesg -E
  237. }
  238.  
  239. # Only try to unmount if the device is mounted
  240. # If it is, try anyway, the dd will (likely) take care of it anyway
  241. if findmnt ${TARGET}1 > /dev/null
  242. then
  243.     umount ${TARGET}1 || /bin/true
  244. fi
  245.  
  246. if findmnt ${TARGET}2 > /dev/null
  247. then
  248.     umount ${TARGET}2 || /bin/true
  249. fi
  250.  
  251. # Only use the emmc_partition function for "special cases", aka veyron devices (aka C100PA)
  252. if [[ $TARGET == "/dev/mmcblk2p" ]] && $TARGET_EMMC
  253. then
  254.     emmc_partition
  255. else
  256.     external_partition $TARGET_NO_P
  257. fi
  258.  
  259. KERNEL_PARTITION=${TARGET}1
  260. ROOT_PARTITION=${TARGET}2
  261.  
  262. echo Writing kernel to partition $KERNEL_PARTITION
  263. dd if=/dev/zero of=$KERNEL_PARTITION bs=512 count=65536
  264. dd if=${BOOT_DEVICE}1 of=$KERNEL_PARTITION
  265.  
  266.  
  267. echo Creating ext4 filesystem on root partition
  268. mkfs.ext4 -F -b 1024 $ROOT_PARTITION
  269. INSTALL_MOUNT=/mnt/install_mount
  270. mkdir -p $INSTALL_MOUNT/
  271.  
  272. mount $ROOT_PARTITION $INSTALL_MOUNT/
  273. echo Syncing live root filesystem with new root filesystem, this will take about 4 minutes...
  274. rsync -ah --info=progress2 --info=name0 --numeric-ids -x / $INSTALL_MOUNT/
  275.  
  276. # Remove the live-fstab and install a base fstab
  277. rm $INSTALL_MOUNT/etc/fstab
  278. echo "${ROOT_PARTITION} / ext4 defaults,noatime 0 1" > $INSTALL_MOUNT/etc/fstab
  279.  
  280. # Unmount root
  281. umount $ROOT_PARTITION
  282.  
  283. # Run file system check on root
  284. echo Running fsck
  285. e2fsck -p -f $ROOT_PARTITION
  286.  
  287. # Done, reboot
  288. echo "Please remove the booted device after power off is complete"
  289. while true; do
  290.     read -r -p "Reboot? [y/N]" re
  291.     case $re in
  292.         [Yy]* ) reboot;;
  293.         [Nn]* ) exit;;
  294.         * ) echo "Please answer y or n";;
  295.     esac
  296. done
  297.  
  298.  
  299. ##########################################################################################
  300. # Congrats, you have now replaced Chrome OS on your Chromebook with Debian Buster (v10). #
  301. # Feel free to install updates, Debian packages, etc.                                    #
  302. ##########################################################################################
  303.  
  304.  
  305. ######################################################################################################
  306. # THE FOLLOWING IS COMPLETELY OPTIONAL AND ARE HERE AS MY OWN PERSONAL NOTES FOR POST-INSTALL STEPS. #
  307. # ALL COMMANDS ASSUME YOU ARE RUNNING AS ROOT USER.                                                  #
  308. ######################################################################################################
  309.  
  310.  
  311. ########################################################################################################################
  312. # Connect to WiFi using cli (the wifi.sh script found in the Debian image doesn't survive reboots.  This method will.) #
  313. ########################################################################################################################
  314. #
  315. # Run the following:
  316. #     apt update && apt install -y wireless-tools
  317. #
  318. # List network status:
  319. #     ip a
  320. #
  321. # List wireless network devices:
  322. #     iw dev
  323. #
  324. # Turn on the wireless networking device (note, wlan0 is an example, use the one from the previous step for your device):
  325. #     ip link set wlan0 up
  326. #
  327. # Scan for available networks (you can skip if you already know your WLAN SSID):
  328. #     su -l
  329. #     iwlist scan
  330. #
  331. # Edit wlan configs with your WLAN network settings:
  332. #     nano /etc/network/interfaces
  333. #
  334. # Below is an example config:
  335. #
  336. #     # My wifi device
  337. #     allow-hotplug wlan0
  338. #     iface wlan0 inet dhcp
  339. #     wpa-ssid MY SSID
  340. #     wpa-psk PASSWORD
  341. #
  342. # Now, connect to the WLAN:
  343. #     ifup wlan0
  344. #
  345. # Verify the connection:
  346. #     iw wlan0 link
  347. #     ip a
  348. #
  349.  
  350.  
  351. ################
  352. # Disable IPv6 #
  353. ################
  354. #
  355. # Run the following:
  356. #     nano /etc/sysctl.conf
  357. #
  358. # Add the following:
  359. #
  360. #     # disable IPv6
  361. #     net.ipv6.conf.all.disable_ipv6 = 1
  362. #     net.ipv6.conf.default.disable_ipv6 = 1
  363. #     net.ipv6.conf.lo.disable_ipv6 = 1
  364. #
  365. # Save and close the file.
  366. #
  367. # Run the following to reload sysctl config:
  368. #
  369. #     sysctl -p
  370. #
  371. # Verify IPv6 is now disabled:
  372. #
  373. #     ip a
  374. #     ifconfig wlan0
  375. #
  376.  
  377.  
  378. ##############################################
  379. # Temporarily turn off WiFi power management #
  380. ##############################################
  381. #
  382. # View current power saving settings:
  383. #    iw dev wlan0 get power_save
  384. #
  385. # Turn power-saving off:
  386. #    iw dev wlan0 set power_save off
  387. #
  388.  
  389.  
  390. #####################################################################
  391. # Create systemd service to automatically disable WiFi power-saving #
  392. #####################################################################
  393. #
  394. # Add script:
  395. #     nano /root/disable_wifi_powermanagement.sh
  396. #
  397. # Add the following to script:
  398. #     #!/bin/sh
  399. #
  400. #     iw dev wlan0 set power_save off
  401. #
  402. # Save changes and exit.
  403. #
  404. # Make the script executable:
  405. #     chmod +x /root/disable_wifi_powermanagement.sh
  406. #
  407. # Create a service to trigger the script:
  408. #     nano /etc/systemd/system/disable-wifi-powermanagement.service
  409. #
  410. # Add the following:
  411. #     [Unit]
  412. #     Description=Disables WiFi Power Management
  413. #     After=network.target
  414. #     After=network-online.target
  415. #
  416. #     [Service]
  417. #     Type=simple
  418. #     ExecStart=/bin/sh /root/disable_wifi_powermanagement.sh
  419. #
  420. #     [Install]
  421. #     WantedBy=multi-user.target
  422. #
  423. # Save changes, change permissions:
  424. #     chmod 644 /etc/systemd/system/disable-wifi-powermanagement.service
  425. #     systemctl daemon-reload
  426. #
  427. # Start the service:
  428. #     systemctl start /etc/systemd/system/disable-wifi-powermanagement.service
  429. #
  430. # Check if power-saving has been disabled:
  431. #     iwconfig wlan0 | grep "Power Management:"
  432. #
  433. # Start service at automatically:
  434. #     systemctl enable /etc/systemd/system/disable-wifi-powermanagement.service
  435. #
  436.  
  437.  
  438. ###############
  439. # Install SSH #
  440. ###############
  441. #
  442. # Run the following
  443. #     apt update && apt install -y openssh-client openssh-server
  444. #
  445. # Configure SSH
  446. #     nano /etc/ssh/sshd_config
  447. #
  448. # Change the following (set the port to your preference):
  449. #
  450. #     Port 55555
  451. #     PermitRootLogin yes
  452. #
  453. # Save changes, then restart SSH:
  454. #     systemctl restart ssh
  455. #
  456.  
  457. #######################
  458. # Configure Time Zone #
  459. #######################
  460. #
  461. #     timedatectl set-timezone America/Chicago
  462. #
  463.  
  464.  
  465. #################################
  466. # Configure Time Sync w/ Google #
  467. #################################
  468. #
  469. # Run the following:
  470. #     apt purge ntp
  471. #     nano /etc/systemd/timesyncd.conf
  472. #
  473. # Paste the following:
  474. #     [Time]
  475. #     NTP=time.google.com
  476. #
  477. # Run the following:
  478. #     timedatectl set-ntp true
  479. #     timedatectl status
  480. #     timedatectl timesync-status
  481. #
  482.  
  483.  
  484. #######################################################
  485. # Prevent device from powering off when lid is closed #
  486. #######################################################
  487. #
  488. # Run the following:
  489. #     nano /etc/systemd/logind.conf
  490. #
  491. # Find and set the following line:
  492. #
  493. #     HandleLidSwitch=ignore
  494. #
  495. # Save changes.
  496. #
  497. # Restart the login service:
  498. #     service systemd-logind restart
  499. #
  500.  
  501.  
  502. #######################################################################
  503. # Have the screen automatically turn off after 1 minute of inactivity #
  504. #######################################################################
  505. #
  506. # Run the following:
  507. #     nano /etc/systemd/system/enable-console-blanking.service
  508. #
  509. # Add the following to the file:
  510. #     [Unit]
  511. #     Description=Enable virtual console blanking
  512. #    
  513. #     [Service]
  514. #     Type=oneshot
  515. #     Environment=TERM=linux
  516. #     StandardOutput=tty
  517. #     TTYPath=/dev/console
  518. #     ExecStart=/usr/bin/setterm -blank 1
  519. #    
  520. #     [Install]
  521. #     WantedBy=multi-user.target
  522. #
  523. # Set permissions:
  524. #     chmod 664 /etc/systemd/system/enable-console-blanking.service
  525. #     systemctl daemon-reload
  526. #
  527. # Enable the new service:
  528. #     systemctl start enable-console-blanking.service
  529. #
  530. # Automatically run new service at boot:
  531. #     systemctl enable enable-console-blanking.service
  532. #
  533. # Reboot the machine.
  534. #     reboot
  535. #
  536.  
  537.  
  538. #############################################################
  539. # Update certificate cache (so SSH, SCP and curl will work) #
  540. #############################################################
  541. #
  542. # Run the following:
  543. #    update-ca-certificates --fresh
  544. #
  545.  
  546.  
  547. ################################################################
  548. # Configure locale (remove/prevent unwanted localization data) #
  549. ################################################################
  550. #
  551. # Run the following:
  552. #    dpkg-reconfigure locales
  553. #    apt update && apt install -y localepurge
  554. #
  555.  
  556.  
  557. ##################################
  558. # Set CPU scaling to performance #
  559. ##################################
  560. #
  561. # Create script to change scaling:
  562. #     nano /root/set_scaling_to_performance.sh
  563. #
  564. # Add the following to the file:
  565. #     #!/bin/sh
  566. #     echo performance > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
  567. #     echo performance > /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor
  568. #     echo performance > /sys/devices/system/cpu/cpu2/cpufreq/scaling_governor
  569. #     echo performance > /sys/devices/system/cpu/cpu3/cpufreq/scaling_governor
  570. #
  571. # Save the file and make it executable:
  572. #     chmod +x /root/set_scaling_to_performance.sh
  573. #
  574. # Create a service to call the script:
  575. #     nano /etc/systemd/system/set-cpu-scaling.service
  576. #
  577. # Add the following to the file:
  578. #     [Unit]
  579. #     Description=Sets CPU scaling to Performance
  580. #    
  581. #     [Service]
  582. #     Type=simple
  583. #     ExecStart=/bin/sh /root/set_scaling_to_performance.sh
  584. #    
  585. #     [Install]
  586. #     WantedBy=multi-user.target
  587. #
  588. # Now run:
  589. #     chmod 664 /etc/systemd/system/set-cpu-scaling.service
  590. #     systemctl daemon-reload
  591. #
  592. # Start the service:
  593. #     systemctl start set-cpu-scaling.service
  594. #
  595. # Verify governor now set to "Performance":
  596. #
  597. #     cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
  598. #
  599. # Run the service automatically at boot:
  600. #     systemctl enable set-cpu-scaling.service
  601. #
  602.  
  603.  
  604. ##########################
  605. # Disable soundcard/ALSA #
  606. ##########################
  607. #
  608. # Run the following:
  609. #     nano /etc/modprobe.d/sound.blacklist.conf
  610. #
  611. # Add the following to the file:
  612. #     blacklist snd_soc_rockchip_max98090
  613. #
  614. # Save changes and exit.
  615. #
  616. # Now run:
  617. #     mkdir /etc/modprobe.d/disabled && mv /etc/modprobe.d/alsa.conf disabled/
  618. #
  619.  
  620.  
  621. #########################################
  622. # Install Unbound (Reverse DNS Service) #
  623. #########################################
  624. #
  625. # Run the following:
  626. #     apt update && apt install -y unbound
  627. #
  628. # Get newest root hints:
  629. #     wget https://www.internic.net/domain/named.root -qO- | tee /var/lib/unbound/root.hints
  630. #
  631. # Configure unbound as needed:
  632. #     nano /etc/unbound/unbound.conf.d/pihole-flip.conf
  633. #
  634. # Restart unbound service:
  635. #     service unbound restart
  636. #
  637.  
  638.  
  639. #############################################
  640. # Install RpiMonitor (Raspberry Pi Monitor) #
  641. #############################################
  642. #
  643. # Run the following:
  644. #     apt update && apt install -y dirmngr
  645. #
  646. #     apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 2C0D3C0F
  647. #
  648. #     echo "deb https://www.giteduberger.fr rpimonitor/" > /etc/apt/sources.list.d/rpimonitor.list
  649. #
  650. #     apt update && apt install -y rpimonitor
  651. #
  652. #     /etc/init.d/rpimonitor update
  653. #
  654.  
  655.  
  656. #######################################################
  657. # Adjust RpiMonitor templates for Chromebook Hardware #
  658. #######################################################
  659. #
  660. # Edit main template that chooses which templates to load:
  661. #     nano /etc/rpimonitor/template/raspbian.conf
  662. #
  663. # Make the following changes:
  664. #
  665. #     include=/etc/rpimonitor/template/version.conf
  666. #     include=/etc/rpimonitor/template/uptime.conf
  667. #     include=/etc/rpimonitor/template/cpu.conf
  668. #     include=/etc/rpimonitor/template/temperature.conf
  669. #     include=/etc/rpimonitor/template/memory.conf
  670. #     #include=/etc/rpimonitor/template/swap.conf
  671. #     #include=/etc/rpimonitor/template/sdcard.conf
  672. #     #include=/etc/rpimonitor/template/network.conf
  673. #    
  674. #     #include=/etc/rpimonitor/template/printer.conf
  675. #     include=/etc/rpimonitor/template/storage.conf
  676. #     include=/etc/rpimonitor/template/services.conf
  677. #     include=/etc/rpimonitor/template/wlan.conf
  678. #     #include=/etc/rpimonitor/template/dht11.conf
  679. #     #include=/etc/rpimonitor/template/entropy.conf
  680. #
  681. # Edit version file to remove unneeded field:
  682. #     nano /etc/rpimonitor/template/version.conf
  683. #
  684. # Make the following changes:
  685. #
  686. #     #web.status.1.content.1.line.4='Firmware: <b>' + data.firmware + '</b>'
  687. #     web.status.1.content.1.line.4='Package(s): <b>' + data.upgrade + '</b>' + ShowInfo('packages','Package(s) upgradable(s)',data.packages)
  688. #
  689. # Edit the CPU file to adjust for the Chromebook Flip
  690. #     nano /etc/rpimonitor/template/cpu.conf
  691. #
  692. # Make the following changes to remove voltage readings since that won't work for Rockchip:
  693. #
  694. #     #dynamic.2.name=cpu_voltage
  695. #     #dynamic.2.source=vcgencmd measure_volts core
  696. #     #dynamic.2.regexp=(\d+.\d+)V
  697. #     #dynamic.2.postprocess=
  698. #     #dynamic.2.rrd=
  699. #
  700. # Edit the Temperature file to adjust for Chromebook Flip/Rockchip:
  701. #     nano /etc/rpimonitor/template/temperature.conf
  702. #
  703. # Make the following changes:
  704. #
  705. #     dynamic.12.source=/sys/devices/virtual/thermal/thermal_zone1/temp
  706. #
  707. #     #web.status.1.content.4.line.1="CPU Temperature: <b>"+data.soc_temp+"&deg;C</b>"
  708. #     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)
  709. #     #web.status.1.content.4.line.1=JustGageBar("Temperature", "°C", 40, data.soc_temp, 80, 100, 80)
  710. #
  711. # Edit the storage template to use the internal EMMC drive:
  712. #     nano /etc/rpimonitor/template/storage.conf
  713. #
  714. # Make the following changes
  715. #
  716. #     static.10.name=storage1_total
  717. #     static.10.source=df -t ext4
  718. #     static.10.regexp=/dev/root\s+(\d+)
  719. #     static.10.postprocess=$1/1024
  720. #    
  721. #     #static.11.name=storage2_total
  722. #     #static.11.source=df -t ext4
  723. #     #static.11.regexp=sda3\s+(\d+)
  724. #     #static.11.postprocess=$1/1024
  725. #    
  726. #     dynamic.14.name=storage1_used
  727. #     dynamic.14.source=df -t ext4
  728. #     dynamic.14.regexp=/dev/root\s+\d+\s+(\d+)
  729. #     dynamic.14.postprocess=$1/1024
  730. #     dynamic.14.rrd=GAUGE
  731. #    
  732. #     #dynamic.15.name=storage2_used
  733. #     #dynamic.15.source=df -t ext4
  734. #     #dynamic.15.regexp=sda3\s+\d+\s+(\d+)
  735. #     #dynamic.15.postprocess=$1/1024
  736. #     #dynamic.15.rrd=GAUGE
  737. #    
  738. #     web.status.1.content.9.name=Storage
  739. #     web.status.1.content.9.icon=usb_hdd.png
  740. #     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)
  741. #     #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)
  742. #    
  743. #     web.statistics.1.content.9.name=Storage
  744. #     web.statistics.1.content.9.graph.1=storage1_total
  745. #     web.statistics.1.content.9.graph.2=storage1_used
  746. #     web.statistics.1.content.9.ds_graph_options.storage1_total.label=EMMC total space (MB)
  747. #     web.statistics.1.content.9.ds_graph_options.storage1_total.color="#FF7777"
  748. #     web.statistics.1.content.9.ds_graph_options.storage1_used.label=EMMC used space (MB)
  749. #     web.statistics.1.content.9.ds_graph_options.storage1_used.lines={ fill: true }
  750. #     web.statistics.1.content.9.ds_graph_options.storage1_used.color="#7777FF"
  751. #    
  752. #     #web.statistics.1.content.10.name=Storage2
  753. #     #web.statistics.1.content.10.graph.1=storage2_total
  754. #     #web.statistics.1.content.10.graph.2=storage2_used
  755. #     #web.statistics.1.content.10.ds_graph_options.storage2_total.label=Storage2 total space (MB)
  756. #     #web.statistics.1.content.10.ds_graph_options.storage2_total.color="#FF7777"
  757. #     #web.statistics.1.content.10.ds_graph_options.storage2_used.label=Storage2 used space (MB)
  758. #     #web.statistics.1.content.10.ds_graph_options.storage2_used.lines={ fill: true }
  759. #     #web.statistics.1.content.10.ds_graph_options.storage2_used.color="#7777FF"
  760. #
  761. # Edit the WiFi template:
  762. #     nano /etc/rpimonitor/wlan.conf
  763. #
  764. # Make the following changes:
  765. #
  766. #     dynamic.18.name=wifi_received
  767. #     dynamic.18.source=/sys/class/net/wlan0/statistics/rx_bytes
  768. #     dynamic.18.regexp=(.*)
  769. #     dynamic.18.postprocess=$1*-1
  770. #     dynamic.18.rrd=DERIVE
  771. #     dynamic.18.max=0
  772. #    
  773. #     dynamic.19.name=wifi_send
  774. #     dynamic.19.source=/sys/class/net/wlan0/statistics/tx_bytes
  775. #     dynamic.19.regexp=(.*)
  776. #     dynamic.19.postprocess=
  777. #     dynamic.19.rrd=DERIVE
  778. #     dynamic.19.min=0
  779. #    
  780. #     dynamic.20.name=ssid
  781. #     dynamic.20.source=iw wlan0 info | grep ssid | cut -c 7-
  782. #     dynamic.20.regexp=(.*)
  783. #    
  784. #     dynamic.21.name=channel
  785. #     dynamic.21.source=iw wlan0 info | grep "channel"
  786. #     dynamic.21.regexp=(.*)
  787. #    
  788. #     dynamic.22.name=mac
  789. #     dynamic.22.source=iw wlan0 info | grep addr | cut -c 7- | tr a-z A-Z
  790. #     dynamic.22.regexp=(.*)
  791. #    
  792. #     dynamic.23.name=linkspeed
  793. #     dynamic.23.source=iw dev wlan0 link | grep rx | cut -c 14-
  794. #     dynamic.23.regexp=(.*)
  795. #    
  796. #     dynamic.24.name=powermanagement
  797. #     dynamic.24.source=iwconfig wlan0 | grep "Power Management:" | cut -c 28-
  798. #     dynamic.24.regexp=(.*)
  799. #    
  800. #     web.status.1.content.9.name=WiFi
  801. #     web.status.1.content.9.icon=wifi.png
  802. #     web.status.1.content.9.line.1="SSID: <b>"+data.ssid+"</b>"
  803. #     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>"
  804. #     web.status.1.content.9.line.3="Link Speed: <b>"+data.linkspeed+"</b>"
  805. #     web.status.1.content.9.line.4="Connection: "+data.channel
  806. #     web.status.1.content.9.line.5="Power Management: <b>"+data.powermanagement+"</b>"
  807. #     web.status.1.content.9.line.6="MAC: <b>"+data.mac+"</b>"
  808. #    
  809. #     web.statistics.1.content.9.name=WiFi
  810. #     web.statistics.1.content.9.graph.1=wifi_send
  811. #     web.statistics.1.content.9.graph.2=wifi_received
  812. #     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" }, }
  813. #     web.statistics.1.content.9.ds_graph_options.wifi_send.label=Upload bandwidth (bits)
  814. #     web.statistics.1.content.9.ds_graph_options.wifi_send.lines={ fill: true }
  815. #     web.statistics.1.content.9.ds_graph_options.wifi_send.color="#FF7777"
  816. #     web.statistics.1.content.9.ds_graph_options.wifi_received.label=Download bandwidth (bits)
  817. #     web.statistics.1.content.9.ds_graph_options.wifi_received.lines={ fill: true }
  818. #     web.statistics.1.content.9.ds_graph_options.wifi_received.color="#77FF77"
  819. #
  820. # Edit the services template to monitor services on the device:
  821. #     nano /etc/rpimonitor/services.conf
  822. #
  823. # Make the following changes:
  824. #
  825. #     dynamic.1.name=ssh
  826. #     dynamic.1.source=netstat -nlt
  827. #     dynamic.1.regexp=tcp .*:(55555).*LISTEN
  828. #    
  829. #     dynamic.2.name=rpimonitor
  830. #     dynamic.2.source=netstat -nlt
  831. #     dynamic.2.regexp=tcp .*:(8888).*LISTEN
  832. #    
  833. #     dynamic.3.name=http
  834. #     dynamic.3.source=netstat -nlt
  835. #     dynamic.3.regexp=tcp .*:(80).*LISTEN
  836. #    
  837. #     dynamic.4.name=unbound
  838. #     dynamic.4.source=netstat -nlt
  839. #     dynamic.4.regexp=tcp .*:(5335).*LISTEN
  840. #    
  841. #     dynamic.5.name=dns
  842. #     dynamic.5.source=netstat -nlt
  843. #     dynamic.5.regexp=tcp .*:(53).*LISTEN
  844. #    
  845. #     dynamic.6.name=pihole
  846. #     dynamic.6.source=netstat -nlt
  847. #     dynamic.6.regexp=tcp .*:(4711).*LISTEN
  848. #    
  849. #     #dynamic.4.name=https
  850. #     #dynamic.4.source=netstat -nlt
  851. #     #dynamic.4.regexp=tcp .*:(443).*LISTEN
  852. #    
  853. #     #dynamic.5.name=mysql
  854. #     #dynamic.5.source=netstat -nlt
  855. #     #dynamic.5.regexp=tcp .*:(3306).*LISTEN
  856. #    
  857. #     web.status.1.content.1.name=Services
  858. #     web.status.1.content.1.icon=daemons.png
  859. #     #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")
  860. #     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")
  861. #
  862. # Now, restart the RpiMonitor service and log into it to see the changes.
  863. #     service rpimonitor restart
  864. #
  865. # Note: pihole-FTL will be red until after the next portion of this is completed.
  866. #
  867.  
  868.  
  869. ###################
  870. # Install Pi-Hole #
  871. ###################
  872. #
  873. # Run the following:
  874. #     apt update && apt install -y curl
  875. #     curl -sSL https://install.pi-hole.net | bash
  876. #
  877. # Change Pi-Hole Password:
  878. #     pihole -a -p
  879. #
  880.  
  881.  
  882. ##################################################
  883. # Find PiHole temp settings file (for reference) #
  884. ##################################################
  885. #
  886. # Run the follosing:
  887. #     grep -rnw /var/www/html -e 'temp'
  888. #
  889. # Edit Pi-Hole for Chromebook Flip Hardware Temp Readings:
  890. #     nano /var/www/html/admin/scripts/pi-hole/php/header.php
  891. #
  892. # Make the following adjustments:
  893. #
  894. #     // Try to get temperature value from different places (OS dependent)
  895. #    
  896. #     // Chromebook Flip
  897. #     if (file_exists("/sys/devices/virtual/thermal/thermal_zone1/temp"))
  898. #     {
  899. #         $output = rtrim(file_get_contents("/sys/devices/virtual/thermal/thermal_zone1/temp"));
  900. #     }
  901. #     else
  902. #     {
  903. #         if(file_exists("/sys/class/thermal/thermal_zone0/temp"))
  904. #         {
  905. #             $output = rtrim(file_get_contents("/sys/class/thermal/thermal_zone0/temp"));
  906. #         }
  907. #         elseif (file_exists("/sys/class/hwmon/hwmon0/temp1_input"))
  908. #         {
  909. #             $output = rtrim(file_get_contents("/sys/class/hwmon/hwmon0/temp1_input"));
  910. #         }
  911. #         else
  912. #         {
  913. #             $output = "";
  914. #         }
  915. #     }
  916. #
  917.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement