feat: provision user
This commit is contained in:
parent
8f150a20ef
commit
27ba74885f
1 changed files with 40 additions and 0 deletions
|
|
@ -46,14 +46,54 @@ network:
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
|
provision_user () {
|
||||||
|
mnt_point=$1
|
||||||
|
|
||||||
|
echo "Provision user"
|
||||||
|
if [ -f $ssh_key ]; then
|
||||||
|
# Load key from file
|
||||||
|
echo "Loading ssh key from file $ssh_key"
|
||||||
|
ssh_key=$(<$ssh_key)
|
||||||
|
fi
|
||||||
|
|
||||||
|
cat > $mnt_point/user-data <<EOF
|
||||||
|
#cloud-config
|
||||||
|
|
||||||
|
hostname: raspberry-pi
|
||||||
|
manage_etc_hosts: true
|
||||||
|
|
||||||
|
timezone: Europe/Berlin
|
||||||
|
|
||||||
|
package_update: true
|
||||||
|
package_upgrade: true
|
||||||
|
|
||||||
|
enable_ssh: true
|
||||||
|
|
||||||
|
users:
|
||||||
|
- name: $username
|
||||||
|
group: users,adm,dialout,audio,netdev,video,plugdev,cdrom,games,input,gpio,spi,i2c,render,sudo
|
||||||
|
shell: /bin/bash
|
||||||
|
lock_passwd: false
|
||||||
|
plain_text_password: $userpw
|
||||||
|
sudo: ALL=(ALL) ALL:ALL
|
||||||
|
ssh_authorized_keys:
|
||||||
|
- $ssh_key
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
read -e -p "Compressed Image file: " IMG_FILE
|
read -e -p "Compressed Image file: " IMG_FILE
|
||||||
read -e -p "SD Card: " SD_CARD
|
read -e -p "SD Card: " SD_CARD
|
||||||
read -e -p "IP-Address with prefix (comma separated): " NET_ADDR
|
read -e -p "IP-Address with prefix (comma separated): " NET_ADDR
|
||||||
|
read -e -p "Username: " username
|
||||||
|
read -s -p "Password: " userpw
|
||||||
|
echo
|
||||||
|
read -e -p "SSH-Key: " ssh_key
|
||||||
|
|
||||||
flash_sd "$IMG_FILE" "$SD_CARD"
|
flash_sd "$IMG_FILE" "$SD_CARD"
|
||||||
enlarge_partition "$SD_CARD"
|
enlarge_partition "$SD_CARD"
|
||||||
mnt_handle=$(mount_temporary "1")
|
mnt_handle=$(mount_temporary "1")
|
||||||
|
|
||||||
provision_network $mnt_handle
|
provision_network $mnt_handle
|
||||||
|
provision_user $mnt_handle
|
||||||
|
|
||||||
unmount_temporary $mnt_handle
|
unmount_temporary $mnt_handle
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue