Initial commit
commit
5697acff83
@ -0,0 +1,124 @@
|
||||
# Steady Companion PI
|
||||
|
||||
## Installation
|
||||
|
||||
1. Flash (Companion PI)[https://user.bitfocus.io/docs/companion-pi] on a SD card
|
||||
|
||||
1. Paste the following to `userconf.txt` on the boot partition
|
||||
|
||||
```
|
||||
pi:$6$QBrcIp1QtqQX2WmL$GTnNhJ1RKazyv81T3dcIGi/aaxQx8szUDDeMjRQkQvSgucMf7VtDlPnfggghhBPDfdaD.qeE7Dy9qaBBx9v9x1
|
||||
ip:$6$4SrdjLRwj2lJ9XHR$x4Ro/m.LCuFUdfrwG7CWZUktMk0spvIIWoic2litVMEMWBeqjWJ3t.ZeRCEH5LYS5rWxc3bhKuCs6nVTzR9S7/
|
||||
```
|
||||
|
||||
1. Insert the SD card and boot the PI
|
||||
|
||||
First time it boots, it should use dhcp.
|
||||
|
||||
1. SSH to the PI and run the following commands
|
||||
|
||||
1. Set info on login screen
|
||||
|
||||
```bash
|
||||
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
|
||||
```
|
||||
|
||||
1. Add shell script for ip user
|
||||
|
||||
```bash
|
||||
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 device modify eth0 ipv4.method auto
|
||||
|
||||
# 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
|
||||
```
|
||||
|
||||
1. Make script executable
|
||||
|
||||
```bash
|
||||
sudo chmod +x /ip.sh
|
||||
```
|
||||
|
||||
1. Add the user `ip`
|
||||
|
||||
```bash
|
||||
sudo useradd ip --shell /ip.sh -p ip --create-home
|
||||
|
||||
1. Silence the login message
|
||||
|
||||
```bash
|
||||
sudo touch /home/ip/.hushlogin
|
||||
```
|
||||
|
||||
1. Allow user `ip` to configure network
|
||||
|
||||
```bash
|
||||
echo "ip ALL=(ALL:ALL) NOPASSWD: /usr/bin/nmcli" | sudo tee -a /etc/sudoers
|
||||
```
|
||||
|
||||
1. Reboot the PI
|
||||
|
||||
```bash
|
||||
sudo reboot
|
||||
```
|
||||
@ -0,0 +1,55 @@
|
||||
#!/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 device modify eth0 ipv4.method auto
|
||||
|
||||
# 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"
|
||||
Loading…
Reference in New Issue