Added missing packages to both the image and the check.
This commit is contained in:
parent
eeeceb8c3b
commit
7b9ac90456
@ -1,237 +0,0 @@
|
||||
#! /bin/bash
|
||||
#
|
||||
# Copyright 2020, Stormux, <storm_dragon@linux-a11y.org>
|
||||
#
|
||||
# This is free software; you can redistribute it and/or modify it under the
|
||||
# terms of the GNU General Public License as published by the Free
|
||||
# Software Foundation; either version 3, or (at your option) any later
|
||||
# version.
|
||||
#
|
||||
# This software is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this package; see the file COPYING. If not, write to the Free
|
||||
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
# 02110-1301, USA.
|
||||
#
|
||||
|
||||
# keep track of mounted status for exit function
|
||||
mounted=1
|
||||
|
||||
set -e # Don't want to destroy stuff if this goes majorly wrong.
|
||||
trap cleanup EXIT # make sure the script cleans up after itself before closing.
|
||||
|
||||
|
||||
cleanup() {
|
||||
if [[ $mounted -eq 0 ]]; then
|
||||
umount -R /mnt
|
||||
partx -d "${loopdev}"
|
||||
losetup --detach "${loopdev}"
|
||||
fi
|
||||
exit 0
|
||||
}
|
||||
|
||||
help() {
|
||||
echo -e "Usage:\n"
|
||||
echo "With no arguments, build with default parameters."
|
||||
for i in "${!command[@]}" ; do
|
||||
echo "-${i/:/ <parameter>}: ${command[${i}]}"
|
||||
done | sort
|
||||
exit 0
|
||||
}
|
||||
|
||||
# Array of command line arguments
|
||||
declare -A command=(
|
||||
[h]="This help screen."
|
||||
[l:]="Language default is en_US."
|
||||
[s:]="image size in GB, default is 8."
|
||||
[v:]="Version of the Raspberry Pi for which you are building. (3|4 default)"
|
||||
[w:]="Full path to netctl profile you want to use, usually located in /etc/netctl."
|
||||
)
|
||||
|
||||
# Convert the keys of the associative array to a format usable by getopts
|
||||
args="${!command[*]}"
|
||||
args="${args//[[:space:]]/}"
|
||||
while getopts "${args}" i ; do
|
||||
case "$i" in
|
||||
h) help;;
|
||||
l)
|
||||
imageLanguage="${OPTARG}.UTF-8"
|
||||
;;
|
||||
s)
|
||||
if [[ "${OPTARG}" =~ ^[[:digit:]]+$ ]]; then
|
||||
imageSize="${OPTARG}G"
|
||||
else
|
||||
echo "Image size must be numeric."
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
v)
|
||||
if [[ "${OPTARG}" =~ ^[34]$ ]]; then
|
||||
imageVersion="${OPTARG}"
|
||||
else
|
||||
echo "Image version must be 3 for the Raspberry Pi 3, or 4 for the Raspberry Pi 4 (default)."
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
w)
|
||||
if [[ -r "${OPTARG}" ]]; then
|
||||
imageWifi="${OPTARG}"
|
||||
else
|
||||
echo "No netctl profile found at ${OPTARG}."
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# make sure variables are set, or use defaults.
|
||||
if [[ -n "${imageWifi}" ]]; then
|
||||
export imageWifi
|
||||
fi
|
||||
export imageVersion="${imageVersion:-4}"
|
||||
export imageSize="${imageSize:-8G}"
|
||||
export imageName="arcroft.img"
|
||||
export imageLanguage="${imageLanguage:-en_US.UTF-8}"
|
||||
|
||||
# Make sure the image file doesn't exist.
|
||||
if [[ -e "$imageName" ]]; then
|
||||
echo "${imageName} exists, please remove or move it for this script to continue."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Make sure this script is ran as root.
|
||||
if [ "$(whoami)" != "root" ] ; then
|
||||
echo "Error: This script must be run as root."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# make sure the needed tools are installed
|
||||
if [[ "$(uname -m)" == "x86_64" ]]; then
|
||||
if ! pacman -Q qemu-user-static &> /dev/null ; then
|
||||
echo "Please install qemu-user-static before continuing."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
for i in parted wget ; do
|
||||
if ! pacman -Q $i &> /dev/null ; then
|
||||
echo "Please install $i before continuing."
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
# 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-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-4-latest.tar.gz"
|
||||
|
||||
fallocate -l "$imageSize" "$imageName"
|
||||
loopdev="$(losetup --find --show "${imageName}")"
|
||||
parted --script "${loopdev}" mklabel msdos mkpart primary fat32 0% 100M mkpart primary ext4 100M 100%
|
||||
mkfs.vfat -F32 "${loopdev}p1"
|
||||
mkfs.ext4 -F "${loopdev}p2"
|
||||
mount "${loopdev}p2" /mnt
|
||||
mkdir /mnt/boot
|
||||
mount "${loopdev}p1" /mnt/boot
|
||||
# Things are mounted now, so set mounted to 0 (bash true)
|
||||
mounted=0
|
||||
wget "${url[$imageVersion]}" -O- | bsdtar -xpf - -C /mnt
|
||||
# Set up wifi
|
||||
if [[ -n "${imageWifi}" ]]; then
|
||||
mkdir -p "/mnt/etc/netctl"
|
||||
cp -v "${imageWifi}" "/mnt/etc/netctl/mycroft"
|
||||
sed -i "s/Interface=.*/Interface=wlan0/" "/mnt/etc/netctl/mycroft"
|
||||
fi
|
||||
# Create Mycroft service file
|
||||
cat << 'EOF' > /mnt/etc/systemd/system/mycroft.service
|
||||
[Unit]
|
||||
Description=Mycroft AI
|
||||
After=pulseaudio.service mycroft-update.service
|
||||
Requires=mycroft-update.service
|
||||
|
||||
[Service]
|
||||
User=mycroft
|
||||
WorkingDirectory=/home/mycroft/
|
||||
ExecStart=/home/mycroft/mycroft-core/bin/mycroft-start all
|
||||
ExecStop=/home/mycroft/mycroft-core/bin/mycroft-stop
|
||||
Type=forking
|
||||
Restart=no
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOF
|
||||
|
||||
cat << 'EOF' > /mnt/etc/systemd/system/mycroft-update.service
|
||||
[Unit]
|
||||
Description=Mycroft AI Update
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
ExecStartPre=/usr/bin/runuser -u mycroft -- /usr/bin/git pull -C /home/mycroft/mycroft-core
|
||||
ExecStart=/usr/bin/bash /home/mycroft/mycroft-core/dev_setup.sh
|
||||
RemainAfterExit=no
|
||||
Type=simple
|
||||
Restart=no
|
||||
EOF
|
||||
|
||||
arch-chroot /mnt << EOF
|
||||
# set up pacman
|
||||
pacman-key --init
|
||||
pacman-key --populate archlinuxarm
|
||||
pacman -Syu --needed --noconfirm base base-devel bash-completion curl dialog espeak flac git icu iw jq libffi libjpeg-turbo mpg123 netctl portaudio pulseaudio pulseaudio-alsa python-gobject python-pip python-setuptools python-virtualenv screen swig wpa_supplicant
|
||||
# set the language
|
||||
sed -i "s/#$imageLanguage/$imageLanguage/" /etc/locale.gen
|
||||
echo "LANG=$imageLanguage" > /etc/locale.conf
|
||||
locale-gen
|
||||
# Set the distribution name.
|
||||
echo 'Arcroft \r (\l)' > /etc/issue
|
||||
echo >> /etc/issue
|
||||
# Change the alarm user to be mycroft
|
||||
usermod -a -g users -G wheel,audio,video -m -d /home/mycroft -l mycroft alarm
|
||||
# Grant sudo privileges to the mycroft user for package installation.
|
||||
echo 'mycroft 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
|
||||
echo -e "mycroft\nmycroft" | passwd "mycroft"
|
||||
# Change to the mycroft user and install some packages
|
||||
sudo su - mycroft
|
||||
git clone https://aur.archlinux.org/yay.git
|
||||
cd yay
|
||||
makepkg -si --noconfirm
|
||||
cd ~
|
||||
rm -rf yay
|
||||
yay -S --needed --noconfirm fann magic-wormhole mimic
|
||||
git clone https://github.com/MycroftAI/mycroft-core.git
|
||||
cd mycroft-core
|
||||
bash dev_setup.sh
|
||||
cd ~
|
||||
exit
|
||||
# Configure sudo for group wheel, remove nopasswd for the mycroft user
|
||||
sed '/mycroft/d' /etc/sudoers.d/wheel
|
||||
sed 's/^# %wheel ALL=(ALL) ALL$/%wheel ALL=(ALL) ALL/' /etc/sudoers.d/wheel
|
||||
# Set the hostname
|
||||
echo mycroft > /etc/hostname
|
||||
|
||||
# Enable services
|
||||
systemctl enable mycroft sshd
|
||||
if [[ -n "${imageWifi}" ]]; then
|
||||
netctl enable "mycroft"
|
||||
fi
|
||||
# Update fstab for Raspberry Pi 4.
|
||||
#[[ $imageVersion -eq 4 ]] && sed -i 's/mmcblk0/mmcblk1/g' /etc/fstab
|
||||
EOF
|
||||
|
||||
# Copy override files into place.
|
||||
cp -rv ../files/etc/* /mnt/etc
|
||||
|
||||
# Exiting calls the cleanup function to unmount.
|
||||
exit 0
|
@ -111,7 +111,7 @@ if [[ "$(uname -m)" == "x86_64" ]]; then
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
for i in parted wget ; do
|
||||
for i in dosfstools parted wget ; do
|
||||
if ! pacman -Q $i &> /dev/null ; then
|
||||
echo "Please install $i before continuing."
|
||||
exit 1
|
||||
@ -140,7 +140,7 @@ arch-chroot /mnt << EOF
|
||||
# set up pacman
|
||||
pacman-key --init
|
||||
pacman-key --populate archlinuxarm
|
||||
pacman -Syu --needed --noconfirm base base-devel bash-completion cronie espeak-ng git
|
||||
pacman -Syu --needed --noconfirm alsa-utils base base-devel bash-completion cronie espeak-ng git wget
|
||||
# set the language
|
||||
sed -i "s/#$imageLanguage/$imageLanguage/" /etc/locale.gen
|
||||
echo "LANG=$imageLanguage" > /etc/locale.conf
|
||||
|
Loading…
Reference in New Issue
Block a user