You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2.9 KiB

Steady Companion PI

Installation

  1. Flash (Companion PI)[https://user.bitfocus.io/docs/companion-pi] on a SD card

  2. Paste the following to userconf.txt on the boot partition

    pi:$6$QBrcIp1QtqQX2WmL$GTnNhJ1RKazyv81T3dcIGi/aaxQx8szUDDeMjRQkQvSgucMf7VtDlPnfggghhBPDfdaD.qeE7Dy9qaBBx9v9x1
    ip:$6$4SrdjLRwj2lJ9XHR$x4Ro/m.LCuFUdfrwG7CWZUktMk0spvIIWoic2litVMEMWBeqjWJ3t.ZeRCEH5LYS5rWxc3bhKuCs6nVTzR9S7/
    
  3. Insert the SD card and boot the PI

    First time it boots, it should use dhcp.

  4. SSH to the PI and run the following commands

    1. Set info on login screen

      sudo tee /etc/issue > /dev/null <<EOT
      Debian GNU/Linux 12 \n \l
      
      Login with the username: pi and password: raspberry
      
      To change the IP of the pi login using username: ip and password: ip
      and you will be able to see and change the current ip
      
      EOT
      
    2. Add shell script for ip user

      sudo tee /ip.sh > /dev/null <<EOT
      #!/bin/bash
      
      # Print the ip address of the raspberry pi
      current_ip=\$(hostname -I | cut -d' ' -f1)
      
      # Print the ip address
      echo "The current ip address is \$current_ip"
      
      # Ask if they want to change the ip address
      echo -n "Do you want to change the ip address? (Y/n) "
      read change_ip
      
      # Exit if they don't want to change the ip address
      if [ "\$change_ip" = "n" ]; then
      	exit 0
      fi
      
      # Ask if they want to use dhcp
      echo -n "Do you want to use dhcp? (y/N) "
      read use_dhcp
      if [ "\$use_dhcp" = "y" ]; then
      	# Set the ip address to dhcp
      	sudo nmcli c modify "Wired connection 1" ipv4.method auto ipv4.addresses "" ipv4.gateway ""
      
      	# Restart the network
      	sudo nmcli c down "Wired connection 1"
      	sudo nmcli c up "Wired connection 1"
      	exit 0
      fi
      
      # Ask for the new ip address
      echo -n "Enter the new ip address: "
      read new_ip
      
      # Ask for the new subnet mask
      echo -n "Enter the new CIDR subnet mask (press enter for default of 24) "
      read subnet_mask
      if [ -z "\$subnet_mask" ]; then
      	subnet_mask="24"
      fi
      
      # Ask for the new gateway
      echo -n "Enter the new gateway (press enter for default of 192.168.25.1) "
      read gateway
      if [ -z "\$gateway" ]; then
      	gateway="192.168.25.1"
      fi
      
      # Set the new ip address
      sudo nmcli c mod "Wired connection 1" ipv4.addresses \$new_ip/\$subnet_mask ipv4.method manual
      sudo nmcli c mod "Wired connection 1" ipv4.gateway \$gateway
      
      # Restart the network
      sudo nmcli c down "Wired connection 1"
      sudo nmcli c up "Wired connection 1"
      
      EOT
      
    3. Make script executable

      sudo chmod +x /ip.sh
      
    4. Add the user ip

      sudo useradd ip --shell /ip.sh -p ip --create-home
      echo -e "ip\nip" | sudo passwd ip
      
    5. Silence the login message

      sudo touch /home/ip/.hushlogin
      
    6. Allow user ip to configure network

      echo "ip ALL=(ALL:ALL) NOPASSWD: /usr/bin/nmcli" | sudo tee -a /etc/sudoers
      
    7. Reboot the PI

      sudo reboot