mirror of
https://github.com/kevinveenbirkenbach/raspberry-pi-tools.git
synced 2024-11-22 18:11:03 +01:00
Solved shellcheck hints
This commit is contained in:
parent
0eab534771
commit
a13fc5413d
@ -4,7 +4,7 @@ This repository contains some shell scripts to install Arch Linux for the Raspbe
|
|||||||
To install Arch Linux on a SD card type in:
|
To install Arch Linux on a SD card type in:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
bash ./sd_card_setup.sh
|
bash ./sd_setup.sh
|
||||||
```
|
```
|
||||||
To backup a SD card type in:
|
To backup a SD card type in:
|
||||||
|
|
||||||
|
21
sd_setup.sh
21
sd_setup.sh
@ -1,8 +1,5 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# @todo execute as non
|
# shellcheck disable=SC2010 # ls | grep allowed
|
||||||
|
|
||||||
# Define constants & variables
|
|
||||||
working_folder="/tmp/raspberry-pi-tools-$(date +%s)"; #Working folder
|
|
||||||
|
|
||||||
echo "Setupscript for Raspberry Pi SD's"
|
echo "Setupscript for Raspberry Pi SD's"
|
||||||
echo
|
echo
|
||||||
@ -12,6 +9,10 @@ echo
|
|||||||
|
|
||||||
echo "Starting setup..."
|
echo "Starting setup..."
|
||||||
|
|
||||||
|
echo "Define working folder..."
|
||||||
|
working_folder="/tmp/raspberry-pi-tools-$(date +%s)"; #Working folder
|
||||||
|
|
||||||
|
|
||||||
echo "Create temporary working folder in $working_folder";
|
echo "Create temporary working folder in $working_folder";
|
||||||
mkdir -v "$working_folder"
|
mkdir -v "$working_folder"
|
||||||
|
|
||||||
@ -23,8 +24,8 @@ fi
|
|||||||
echo "Configure user..."
|
echo "Configure user..."
|
||||||
echo "Please type in a valid username from which the SSH-Key should be copied:"
|
echo "Please type in a valid username from which the SSH-Key should be copied:"
|
||||||
read -r origin_username;
|
read -r origin_username;
|
||||||
getent passwd $origin_username > /dev/null 2 && echo "User $origin_username doesn't exist. Abord program." && exit 1;
|
getent passwd "$origin_username" > /dev/null 2 && echo "User $origin_username doesn't exist. Abord program." && exit 1;
|
||||||
origin_user_home="/home/$username/";
|
origin_user_home="/home/$origin_username/";
|
||||||
|
|
||||||
# Create image folders
|
# Create image folders
|
||||||
image_folder="$origin_user_home/Images/";
|
image_folder="$origin_user_home/Images/";
|
||||||
@ -38,7 +39,7 @@ echo "Select sd-card..."
|
|||||||
echo "List of actual mounted devices:"
|
echo "List of actual mounted devices:"
|
||||||
ls -lasi /dev/ | grep -E "sd|mm"
|
ls -lasi /dev/ | grep -E "sd|mm"
|
||||||
echo
|
echo
|
||||||
while [ \! -b "$sd_card_path" ]
|
while [ ! -b "$sd_card_path" ]
|
||||||
do
|
do
|
||||||
echo "Please type in the name of the correct sd-card."
|
echo "Please type in the name of the correct sd-card."
|
||||||
echo "/dev/:"
|
echo "/dev/:"
|
||||||
@ -115,10 +116,10 @@ esac
|
|||||||
download_url="$base_download_url$imagename"
|
download_url="$base_download_url$imagename"
|
||||||
image_path="$image_folder$image_path"
|
image_path="$image_folder$image_path"
|
||||||
|
|
||||||
if [ \! -f "$image_path" ]
|
if [ ! -f "$image_path" ]
|
||||||
then
|
then
|
||||||
echo "The selected image \"$imagename\" doesn't exist under local path \"$image_path\"."
|
echo "The selected image \"$imagename\" doesn't exist under local path \"$image_path\"."
|
||||||
if [ \! -f "$image_path" ]
|
if [ ! -f "$image_path" ]
|
||||||
then
|
then
|
||||||
echo "Image \"$imagename\" gets downloaded from \"$download_url\""
|
echo "Image \"$imagename\" gets downloaded from \"$download_url\""
|
||||||
wget "$download_url"
|
wget "$download_url"
|
||||||
@ -199,7 +200,7 @@ esac
|
|||||||
|
|
||||||
echo "Define target paths..."
|
echo "Define target paths..."
|
||||||
target_home_path="$root_mount_path/home/";
|
target_home_path="$root_mount_path/home/";
|
||||||
target_username=$(ls $target_home_path);
|
target_username=$(ls "$target_home_path");
|
||||||
target_user_home_folder_path="$target_home_path$target_username/";
|
target_user_home_folder_path="$target_home_path$target_username/";
|
||||||
|
|
||||||
echo "Copy ssh key to target..."
|
echo "Copy ssh key to target..."
|
||||||
|
Loading…
Reference in New Issue
Block a user