Added language support flag, set language in image, improvement to the help system.
This commit is contained in:
parent
7c0c71ab2c
commit
50959e458a
@ -38,7 +38,7 @@ help() {
|
|||||||
echo -e "Usage:\n"
|
echo -e "Usage:\n"
|
||||||
echo "With no arguments, build with default parameters."
|
echo "With no arguments, build with default parameters."
|
||||||
for i in "${!command[@]}" ; do
|
for i in "${!command[@]}" ; do
|
||||||
echo "-${i}: ${command[${i}]}"
|
echo "-${i/:/ <parameter>}: ${command[${i}]}"
|
||||||
done | sort
|
done | sort
|
||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
@ -46,9 +46,10 @@ help() {
|
|||||||
# Array of command line arguments
|
# Array of command line arguments
|
||||||
declare -A command=(
|
declare -A command=(
|
||||||
[h]="This help screen."
|
[h]="This help screen."
|
||||||
[n]="Image name, default is stormux-pi<3|4>-<yyyy-mm-dd>.img"
|
[l:]="Language default is en_US."
|
||||||
[s]="image size in GB, default is 4."
|
[n:]="Image name, default is stormux-pi<3|4>-<yyyy-mm-dd>.img"
|
||||||
[v]="Version of the Raspberry Pi for which you are building. (3|4 default)"
|
[s:]="image size in GB, default is 4."
|
||||||
|
[v:]="Version of the Raspberry Pi for which you are building. (3|4 default)"
|
||||||
)
|
)
|
||||||
|
|
||||||
# Convert the keys of the associative array to a format usable by getopts
|
# Convert the keys of the associative array to a format usable by getopts
|
||||||
@ -56,31 +57,31 @@ args="${!command[*]}"
|
|||||||
args="${args//[[:space:]]/}"
|
args="${args//[[:space:]]/}"
|
||||||
while getopts "${args}" i ; do
|
while getopts "${args}" i ; do
|
||||||
case "$i" in
|
case "$i" in
|
||||||
n)
|
|
||||||
shift
|
|
||||||
imageName="$1"
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
h) help;;
|
h) help;;
|
||||||
|
l)
|
||||||
|
imageLanguage="${OPTARG}.UTF-8"
|
||||||
|
;;
|
||||||
|
n)
|
||||||
|
imageName="${OPTARG}"
|
||||||
|
;;
|
||||||
s)
|
s)
|
||||||
shift
|
if [[ "${OPTARG}" =~ ^[[:digit:]]+$ ]]; then
|
||||||
if [[ "$1" =~ ^[[:digit:]]+$ ]]; then
|
imageSize="${OPTARG}G"
|
||||||
imageSize="${1}G"
|
|
||||||
else
|
else
|
||||||
echo "Image size must be numeric."
|
echo "Image size must be numeric."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
shift
|
|
||||||
;;
|
;;
|
||||||
v)
|
v)
|
||||||
shift
|
if [[ "${OPTARG}" =~ ^[34]$ ]]; then
|
||||||
if [[ "$1" =~ ^[34]$ ]]; then
|
imageVersion="${OPTARG}"
|
||||||
imageVersion="$1"
|
|
||||||
else
|
else
|
||||||
echo "Image version must be 3 for the Raspberry Pi 3, or 4 for the Raspberry Pi 4 (default)."
|
echo "Image version must be 3 for the Raspberry Pi 3, or 4 for the Raspberry Pi 4 (default)."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
shift
|
;;
|
||||||
|
*)
|
||||||
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
@ -89,6 +90,7 @@ done
|
|||||||
export imageVersion="${imageVersion:-4}"
|
export imageVersion="${imageVersion:-4}"
|
||||||
export imageSize="${imageSize:-4G}"
|
export imageSize="${imageSize:-4G}"
|
||||||
export imageName="${imageName:-stormux-pi${imageVersion}-$(date '+%Y-%m-%d').img}"
|
export imageName="${imageName:-stormux-pi${imageVersion}-$(date '+%Y-%m-%d').img}"
|
||||||
|
export imageLanguage="${imageLanguage:-en_US.UTF-8}"
|
||||||
|
|
||||||
# Make sure the image file doesn't exist.
|
# Make sure the image file doesn't exist.
|
||||||
if [[ -e "$imageName" ]]; then
|
if [[ -e "$imageName" ]]; then
|
||||||
@ -118,7 +120,8 @@ done
|
|||||||
|
|
||||||
|
|
||||||
# Url for the image to be downloaded.
|
# Url for the image to be downloaded.
|
||||||
url[3]="http://os.archlinuxarm.org/os/ArchLinuxARM-rpi-aarch64-latest.tar.gz"
|
#url[3]="http://os.archlinuxarm.org/os/ArchLinuxARM-rpi-aarch64-latest.tar.gz"
|
||||||
|
url[3]="http://os.archlinuxarm.org/os/ArchLinuxARM-rpi-2-latest.tar.gz"
|
||||||
#url[4]="http://os.archlinuxarm.org/os/ArchLinuxARM-rpi-aarch64-latest.tar.gz"
|
#url[4]="http://os.archlinuxarm.org/os/ArchLinuxARM-rpi-aarch64-latest.tar.gz"
|
||||||
url[4]="http://os.archlinuxarm.org/os/ArchLinuxARM-rpi-4-latest.tar.gz"
|
url[4]="http://os.archlinuxarm.org/os/ArchLinuxARM-rpi-4-latest.tar.gz"
|
||||||
|
|
||||||
@ -138,6 +141,10 @@ arch-chroot /mnt << EOF
|
|||||||
pacman-key --init
|
pacman-key --init
|
||||||
pacman-key --populate archlinuxarm
|
pacman-key --populate archlinuxarm
|
||||||
pacman -Syu --needed --noconfirm base base-devel bash-completion cronie espeak-ng git
|
pacman -Syu --needed --noconfirm base base-devel bash-completion cronie espeak-ng git
|
||||||
|
# set the language
|
||||||
|
sed -i "s/#$imageLanguage/$imageLanguage/" /etc/locale.gen
|
||||||
|
echo "LANG=$imageLanguage" > /etc/locale.conf
|
||||||
|
locale-gen
|
||||||
# Set the distribution name.
|
# Set the distribution name.
|
||||||
echo 'Stormux \r (\l)' > /etc/issue
|
echo 'Stormux \r (\l)' > /etc/issue
|
||||||
echo >> /etc/issue
|
echo >> /etc/issue
|
||||||
@ -145,6 +152,8 @@ echo >> /etc/issue
|
|||||||
usermod -a -g users -G wheel,audio,video -m -d /home/stormux -l stormux alarm
|
usermod -a -g users -G wheel,audio,video -m -d /home/stormux -l stormux alarm
|
||||||
# Grant sudo privileges to the stormux user for package installation.
|
# Grant sudo privileges to the stormux user for package installation.
|
||||||
echo 'stormux ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers.d/wheel
|
echo 'stormux ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers.d/wheel
|
||||||
|
# Set the password for the root user
|
||||||
|
echo -e "root\nroot" | passwd "root"
|
||||||
# Set the password for the stormux user
|
# Set the password for the stormux user
|
||||||
echo -e "stormux\nstormux" | passwd "stormux"
|
echo -e "stormux\nstormux" | passwd "stormux"
|
||||||
# Change to the stormux user and install some packages
|
# Change to the stormux user and install some packages
|
||||||
|
Loading…
Reference in New Issue
Block a user