mirror of
https://github.com/kevinveenbirkenbach/raspberry-pi-tools.git
synced 2024-11-22 18:11:03 +01:00
Finished changing of user_passwords
This commit is contained in:
parent
25ec5c9bfa
commit
2faf488d58
20
README.md
20
README.md
@ -19,16 +19,16 @@ To install a Linux distribution manually on a SD card type in:
|
|||||||
To pase the configuration to the program use this syntax:
|
To pase the configuration to the program use this syntax:
|
||||||
```bash
|
```bash
|
||||||
(
|
(
|
||||||
echo "$USER" # | The username
|
echo "$USER" # | The username
|
||||||
echo "mmcblk1" # | The device
|
echo "mmcblk1" # | The device
|
||||||
echo "4" # | The raspberry pi number
|
echo "4" # | The raspberry pi number
|
||||||
echo "retropie" # | The operation system
|
echo "retropie" # | The operation system
|
||||||
echo "n" # | Force image download
|
echo "n" # | Force image download
|
||||||
echo "n" # | Transfer image
|
echo "n" # | Transfer image
|
||||||
#echo "n" # ├── Overwrite device before copying
|
#echo "n" # ├── Overwrite device before copying
|
||||||
echo "user_password" # | The user password
|
echo "test12345" # | The user password
|
||||||
echo "root_password" # | The root password
|
echo "test12345" # | The root password
|
||||||
echo "y" # | Copy wifi configurations to target system
|
echo "y" # | Copy wifi configurations to target system
|
||||||
)| sudo bash ./sd_setup.sh
|
)| sudo bash ./sd_setup.sh
|
||||||
```
|
```
|
||||||
|
|
||||||
|
64
sd_setup.sh
64
sd_setup.sh
@ -37,14 +37,14 @@ success(){
|
|||||||
|
|
||||||
destructor(){
|
destructor(){
|
||||||
info "Cleaning up..."
|
info "Cleaning up..."
|
||||||
#umount -v "$chroot_dev_pts_mount_path" || warning "Umounting $chroot_dev_pts_mount_path failed!"
|
sed -i 's/^#CHROOT //g' "$root_mount_path/etc/ld.so.preload"
|
||||||
umount -vR "$boot_mount_path" || warning "Umounting $boot_mount_path failed!"
|
umount -v "$chroot_dev_pts_mount_path" || warning "Umounting $chroot_dev_pts_mount_path failed!"
|
||||||
umount -vR "$boot_mount_path" || warning "Umounting $boot_mount_path failed!"
|
umount -v "$chroot_dev_mount_path" || warning "Umounting $chroot_dev_mount_path failed!"
|
||||||
#umount -v "$chroot_dev_mount_path" || warning "Umounting $chroot_dev_mount_path failed!"
|
umount -v "$chroot_proc_mount_path" || warning "Umounting $chroot_proc_mount_path failed!"
|
||||||
#umount -v "$chroot_proc_mount_path" || warning "Umounting $chroot_proc_mount_path failed!"
|
umount -v "$chroot_sys_mount_path" || warning "Umounting $chroot_sys_mount_path failed!"
|
||||||
#umount -v "$chroot_sys_mount_path" || warning "Umounting $chroot_sys_mount_path failed!"
|
umount -v "$root_mount_path""/boot/" || warning "Umounting $root_mount_path/boot/ failed!"
|
||||||
#umount -v "$root_mount_path" || warning "Umounting $root_mount_path failed!"
|
umount -v "$root_mount_path" || warning "Umounting $root_mount_path failed!"
|
||||||
#umount -v "$boot_mount_path" || warning "Umounting $boot_mount_path failed!"
|
umount -v "$boot_mount_path" || warning "Umounting $boot_mount_path failed!"
|
||||||
rmdir -v "$root_mount_path" || warning "Removing $root_mount_path failed!"
|
rmdir -v "$root_mount_path" || warning "Removing $root_mount_path failed!"
|
||||||
rmdir -v "$boot_mount_path" || warning "Removing $boot_mount_path failed!"
|
rmdir -v "$boot_mount_path" || warning "Removing $boot_mount_path failed!"
|
||||||
rmdir -v "$working_folder" || warning "Removing $working_folder failed!"
|
rmdir -v "$working_folder" || warning "Removing $working_folder failed!"
|
||||||
@ -323,31 +323,39 @@ fi
|
|||||||
|
|
||||||
info "Start chroot procedures..."
|
info "Start chroot procedures..."
|
||||||
info "Mount chroot environments..."
|
info "Mount chroot environments..."
|
||||||
chroot_dev_mount_path="$root_mount_path""dev/"
|
|
||||||
chroot_sys_mount_path="$root_mount_path""sys/"
|
chroot_sys_mount_path="$root_mount_path""sys/"
|
||||||
chroot_proc_mount_path="$root_mount_path""proc/"
|
chroot_proc_mount_path="$root_mount_path""proc/"
|
||||||
#chroot_dev_pts_mount_path="$root_mount_path""dev/pts"
|
chroot_dev_mount_path="$root_mount_path""dev/"
|
||||||
mount --rbind /dev "$chroot_dev_mount_path" || error "Mounting $chroot_dev_mount_path failed."
|
chroot_dev_pts_mount_path="$root_mount_path""dev/pts"
|
||||||
mount -o bind /sys "$chroot_sys_mount_path" || error "Mounting $chroot_sys_mount_path failed."
|
mount --bind "$boot_mount_path" "$root_mount_path""/boot" || error "Mounting $chroot_dev_mount_path failed."
|
||||||
mount mount -t /proc none "$chroot_proc_mount_path" || error "Mounting $chroot_proc_mount_path failed."
|
mount --bind /dev "$chroot_dev_mount_path" || error "Mounting $chroot_dev_mount_path failed."
|
||||||
#mount --bind /dev/pts "$chroot_dev_pts_mount_path" || error "Mounting $chroot_dev_pts_mount_path failed."
|
mount --bind /sys "$chroot_sys_mount_path" || error "Mounting $chroot_sys_mount_path failed."
|
||||||
|
mount --bind /proc "$chroot_proc_mount_path" || error "Mounting $chroot_proc_mount_path failed."
|
||||||
|
mount --bind /dev/pts "$chroot_dev_pts_mount_path" || error "Mounting $chroot_dev_pts_mount_path failed."
|
||||||
|
|
||||||
sudo /mnt/rasp-pi-rootfs/dev
|
sed -i 's/^/#CHROOT /g' /mnt/raspbian/etc/ld.so.preload
|
||||||
sudo /mnt/rasp-pi-rootfs/proc
|
cp -v /usr/bin/qemu-arm-static "$root_mount_path""/usr/bin/" || error "Copy qemu-arm-static failed. The following packages are neccessary: qemu qemu-user-static binfmt-support."
|
||||||
sudo /sys /mnt/rasp-pi-rootfs/sys
|
|
||||||
sudo chroot /mnt/rasp-pi-rootfs
|
|
||||||
|
|
||||||
mv "$root_mount_path""resolv.conf" "$root_mount_path""resolv.conf.bak" || warning "Create the resolv.conf.bak failed"
|
info "Changing passwords on target system..."
|
||||||
cp /etc/resolv.conf "$root_mount_path""/etc/resolv.conf" || error "Copy resolv.conf failed."
|
question "Type in new password: " && read -r password_1
|
||||||
cp /usr/bin/qemu-arm-static "$root_mount_path""/usr/bin/" || error "Copy qemu-arm-static failed."
|
question "Repeat new password\"$target_username\"" && read -r password_2
|
||||||
|
if [ "$password_1" == "$password_2" ]
|
||||||
|
then
|
||||||
|
(
|
||||||
|
echo "(
|
||||||
|
echo '$password_1'
|
||||||
|
echo '$password_1'
|
||||||
|
) | passwd $target_username"
|
||||||
|
echo "(
|
||||||
|
echo '$password_1'
|
||||||
|
echo '$password_1'
|
||||||
|
) | passwd"
|
||||||
|
) | chroot "$root_mount_path" /bin/bash || error "Password change failed."
|
||||||
|
else
|
||||||
|
error "Passwords didn't match."
|
||||||
|
fi
|
||||||
|
|
||||||
info "Change password of user \"$target_username\"..."
|
question "Do you want to copy all Wifi passwords to the device?(y/n)" && read -r copy_wifi
|
||||||
(chroot $root_mount_path /bin/passwd "$target_username") || error "Password change for \"$target_username\" wasn't possible."
|
|
||||||
|
|
||||||
info "Change password of root user..."
|
|
||||||
(chroot $root_mount_path /bin/passwd root) || error "Password change for \"root\" wasn't possible."
|
|
||||||
|
|
||||||
question "Do you want to copy all Wifi passwords to the sd-card?(y/n)" && read -r copy_wifi
|
|
||||||
if [ "$copy_wifi" = "y" ]
|
if [ "$copy_wifi" = "y" ]
|
||||||
then
|
then
|
||||||
origin_wifi_config_path="/etc/NetworkManager/system-connections/"
|
origin_wifi_config_path="/etc/NetworkManager/system-connections/"
|
||||||
|
Loading…
Reference in New Issue
Block a user