mirror of
https://github.com/cimryan/teslausb.git
synced 2026-03-01 04:30:33 +00:00
Don't exit rc.local prematurely
Also silent downloads of scripts.
This commit is contained in:
@@ -50,5 +50,6 @@ Built image on a Raspi running Stretch, for maximum Pi-ception.
|
|||||||
### Image creation TODOs
|
### Image creation TODOs
|
||||||
1. TODO: Patch the hostname to teslausb
|
1. TODO: Patch the hostname to teslausb
|
||||||
1. TODO: I still see some errors during pi-gen about locale, may need to be fixed? stage0/01-locale/debconf en_US.UTF-8
|
1. TODO: I still see some errors during pi-gen about locale, may need to be fixed? stage0/01-locale/debconf en_US.UTF-8
|
||||||
|
1. TODO: Cache the remount packages? Might mess with first boot like `rsyslog`
|
||||||
1. Aspirational TODO: Remove more packages etc to make the boot process faster? OR start from `stage1` if we don't need all of `stage2`
|
1. Aspirational TODO: Remove more packages etc to make the boot process faster? OR start from `stage1` if we don't need all of `stage2`
|
||||||
|
|
||||||
|
|||||||
@@ -61,11 +61,12 @@ function verify_file_exists () {
|
|||||||
|
|
||||||
function verify_setup_file_exists () {
|
function verify_setup_file_exists () {
|
||||||
local file_name="$1"
|
local file_name="$1"
|
||||||
local expected_path="$2"
|
|
||||||
|
|
||||||
if [ ! -e "$expected_path/$file_name" ]
|
if [ -e "$file_name" ]
|
||||||
then
|
then
|
||||||
stop_message "STOP: Didn't find setup script $file_name at $expected_path. Try running the setup script again."
|
good_message "Downloaded $file_name."
|
||||||
|
else
|
||||||
|
stop_message "STOP: Didn't find downloaded script $file_name. Try running the setup script again."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@@ -132,51 +133,49 @@ function download_scripts () {
|
|||||||
then
|
then
|
||||||
mkdir "${BOOT_DIR}/teslausb_setup_scripts"
|
mkdir "${BOOT_DIR}/teslausb_setup_scripts"
|
||||||
# stop_message "ERROR: Failed to make teslausb_setup_scripts and download setup scripts. Ensure you have internet access and run this script again."
|
# stop_message "ERROR: Failed to make teslausb_setup_scripts and download setup scripts. Ensure you have internet access and run this script again."
|
||||||
else
|
fi
|
||||||
pushd "${BOOT_DIR}/teslausb_setup_scripts"
|
cd "${BOOT_DIR}/teslausb_setup_scripts"
|
||||||
|
curl -s -o setup-teslausb-headless https://raw.githubusercontent.com/"$REPO"/teslausb/"$BRANCH"/headless-scripts/setup-teslausb-headless
|
||||||
wget https://raw.githubusercontent.com/"$REPO"/teslausb/"$BRANCH"/headless-scripts/setup-teslausb-headless -O setup-teslausb-headless
|
|
||||||
verify_setup_file_exists "setup-teslausb-headless" "${BOOT_DIR}/teslausb_setup_scripts"
|
verify_setup_file_exists "setup-teslausb-headless" "${BOOT_DIR}/teslausb_setup_scripts"
|
||||||
chmod +x setup-teslausb-headless
|
chmod +x setup-teslausb-headless
|
||||||
good_message "Downloaded main setup script."
|
good_message "Downloaded main setup script."
|
||||||
|
|
||||||
wget https://raw.githubusercontent.com/"$REPO"/teslausb/"$BRANCH"/windows_archive/archiveloop -O archiveloop
|
curl -s -o archiveloop https://raw.githubusercontent.com/"$REPO"/teslausb/"$BRANCH"/windows_archive/archiveloop
|
||||||
# sed s/ARCHIVE_HOST_NAME=archiveserver/ARCHIVE_HOST_NAME=$archiveserver/ ~/archiveloop > /root/bin/archiveloop
|
# sed s/ARCHIVE_HOST_NAME=archiveserver/ARCHIVE_HOST_NAME=$archiveserver/ ~/archiveloop > /root/bin/archiveloop
|
||||||
sed -i'.bak' -e "s/ARCHIVE_HOST_NAME=archiveserver/ARCHIVE_HOST_NAME=$archiveserver/" archiveloop
|
sed -i'.bak' -e "s/ARCHIVE_HOST_NAME=archiveserver/ARCHIVE_HOST_NAME=$archiveserver/" archiveloop
|
||||||
verify_setup_file_exists "archiveloop" "${BOOT_DIR}/teslausb_setup_scripts"
|
verify_setup_file_exists "archiveloop" "${BOOT_DIR}/teslausb_setup_scripts"
|
||||||
chmod +x archiveloop
|
chmod +x archiveloop
|
||||||
|
|
||||||
wget https://raw.githubusercontent.com/"$REPO"/teslausb/"$BRANCH"/windows_archive/archive-teslacam-clips -O archive-teslacam-clips
|
curl -s -o archive-teslacam-clips https://raw.githubusercontent.com/"$REPO"/teslausb/"$BRANCH"/windows_archive/archive-teslacam-clips
|
||||||
verify_setup_file_exists "archive-teslacam-clips" "${BOOT_DIR}/teslausb_setup_scripts"
|
verify_setup_file_exists "archive-teslacam-clips" "${BOOT_DIR}/teslausb_setup_scripts"
|
||||||
chmod +x archive-teslacam-clips
|
chmod +x archive-teslacam-clips
|
||||||
good_message "Configured the archive scripts."
|
good_message "Configured the archive scripts."
|
||||||
|
|
||||||
wget https://raw.githubusercontent.com/"$REPO"/teslausb/"$BRANCH"/windows_archive/remountfs_rw -O remountfs_rw
|
curl -s -o remountfs_rw https://raw.githubusercontent.com/"$REPO"/teslausb/"$BRANCH"/windows_archive/remountfs_rw
|
||||||
verify_setup_file_exists "remountfs_rw" "${BOOT_DIR}/teslausb_setup_scripts"
|
verify_setup_file_exists "remountfs_rw" "${BOOT_DIR}/teslausb_setup_scripts"
|
||||||
chmod +x remountfs_rw
|
chmod +x remountfs_rw
|
||||||
good_message "Downloaded script to remount filesystems read/write if needed (/root/bin/remountfs_rw)."
|
good_message "Downloaded script to remount filesystems read/write if needed (/root/bin/remountfs_rw)."
|
||||||
|
|
||||||
if [ ${user_enabled_pushover} = "true" ]
|
if [ ${user_enabled_pushover} = "true" ]
|
||||||
then
|
then
|
||||||
wget https://raw.githubusercontent.com/"$REPO"/teslausb/"$BRANCH"/windows_archive/send-pushover
|
curl -s -o send-pushover https://raw.githubusercontent.com/"$REPO"/teslausb/"$BRANCH"/windows_archive/send-pushover
|
||||||
verify_setup_file_exists "remountfs_rw" "${BOOT_DIR}/teslausb_setup_scripts"
|
verify_setup_file_exists "remountfs_rw" "${BOOT_DIR}/teslausb_setup_scripts"
|
||||||
chmod +x send-pushover
|
chmod +x send-pushover
|
||||||
good_message "Downloaded Pushover notification script."
|
good_message "Downloaded Pushover notification script."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
good_message "Downloading ancillary setup scripts."
|
good_message "Downloading ancillary setup scripts."
|
||||||
wget https://raw.githubusercontent.com/"$REPO"/teslausb/"$BRANCH"/windows_archive/create-backingfiles-partition.sh -O create-backingfiles-partition.sh
|
curl -s -o create-backingfiles-partition.sh https://raw.githubusercontent.com/"$REPO"/teslausb/"$BRANCH"/windows_archive/create-backingfiles-partition.sh
|
||||||
verify_setup_file_exists "create-backingfiles-partition.sh" "${BOOT_DIR}/teslausb_setup_scripts"
|
verify_setup_file_exists "create-backingfiles-partition.sh" "${BOOT_DIR}/teslausb_setup_scripts"
|
||||||
chmod +x create-backingfiles-partition.sh
|
chmod +x create-backingfiles-partition.sh
|
||||||
wget https://raw.githubusercontent.com/"$REPO"/teslausb/"$BRANCH"/windows_archive/create-backingfiles.sh -O create-backingfiles.sh
|
curl -s -o create-backingfiles.sh https://raw.githubusercontent.com/"$REPO"/teslausb/"$BRANCH"/windows_archive/create-backingfiles.sh
|
||||||
verify_setup_file_exists "create-backingfiles.sh" "${BOOT_DIR}/teslausb_setup_scripts"
|
verify_setup_file_exists "create-backingfiles.sh" "${BOOT_DIR}/teslausb_setup_scripts"
|
||||||
chmod +x create-backingfiles.sh
|
chmod +x create-backingfiles.sh
|
||||||
wget https://raw.githubusercontent.com/"$REPO"/teslausb/"$BRANCH"/windows_archive/make-root-fs-readonly.sh -O make-root-fs-readonly.sh
|
curl -s -o make-root-fs-readonly.sh https://raw.githubusercontent.com/"$REPO"/teslausb/"$BRANCH"/windows_archive/make-root-fs-readonly.sh
|
||||||
verify_setup_file_exists "make-root-fs-readonly.sh" "${BOOT_DIR}/teslausb_setup_scripts"
|
verify_setup_file_exists "make-root-fs-readonly.sh" "${BOOT_DIR}/teslausb_setup_scripts"
|
||||||
chmod +x make-root-fs-readonly.sh
|
chmod +x make-root-fs-readonly.sh
|
||||||
popd
|
cd -
|
||||||
good_message "All scripts downloaded and configured."
|
good_message "All scripts downloaded and configured."
|
||||||
fi
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ function check_variable () {
|
|||||||
then
|
then
|
||||||
echo "STOP: Define the variable $var_name like this: export $var_name=value"
|
echo "STOP: Define the variable $var_name like this: export $var_name=value"
|
||||||
setup_log "SETUP FAILED: Define the variable $var_name as export $var_name=value in /boot/teslausb_setup_variables.conf"
|
setup_log "SETUP FAILED: Define the variable $var_name as export $var_name=value in /boot/teslausb_setup_variables.conf"
|
||||||
/tmp/stage_flash 10 &>/dev/null
|
/etc/stage_flash 10
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@@ -80,7 +80,7 @@ function check_available_space () {
|
|||||||
if [ "$available_space" -lt 4294967296 ]
|
if [ "$available_space" -lt 4294967296 ]
|
||||||
then
|
then
|
||||||
setup_log "ERROR: The MicroSD card is too small. Stopping setup."
|
setup_log "ERROR: The MicroSD card is too small. Stopping setup."
|
||||||
/tmp/stage_flash 10 &>/dev/null
|
/etc/stage_flash 10
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -212,19 +212,20 @@ sleep 5
|
|||||||
|
|
||||||
# SETUP STAGE 1 - Check variables file
|
# SETUP STAGE 1 - Check variables file
|
||||||
|
|
||||||
/tmp/stage_flash 1 &>/dev/null
|
/etc/stage_flash 1
|
||||||
|
|
||||||
setup_log "SETUP STAGE 1: Check variables file."
|
setup_log "SETUP STAGE 1: Check variables file."
|
||||||
if [ ! -e /boot/teslausb_setup_variables.conf ]
|
if [ ! -e /boot/teslausb_setup_variables.conf ]
|
||||||
then
|
then
|
||||||
setup_log "ERROR: teslausb_setup_variables.conf file not found. Can't continue setup."
|
setup_log "ERROR: teslausb_setup_variables.conf file not found. Can't continue setup."
|
||||||
/tmp/stage_flash 10 &>/dev/null
|
/etc/stage_flash 10
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
source /boot/teslausb_setup_variables.conf
|
source /boot/teslausb_setup_variables.conf
|
||||||
|
|
||||||
# SETUP STAGE 2 - Validate variables. This should never fail but just in case.
|
# SETUP STAGE 2 - Validate variables. This should never fail but just in case.
|
||||||
/tmp/stage_flash 2 &>/dev/null
|
/etc/stage_flash 2
|
||||||
|
|
||||||
setup_log "SETUP STAGE 2: Verifying environment variables..."
|
setup_log "SETUP STAGE 2: Verifying environment variables..."
|
||||||
|
|
||||||
@@ -241,7 +242,7 @@ check_archive_server_reachable
|
|||||||
# SETUP STAGE 3
|
# SETUP STAGE 3
|
||||||
|
|
||||||
setup_log "SETUP STAGE 3: Check available space."
|
setup_log "SETUP STAGE 3: Check available space."
|
||||||
/tmp/stage_flash 3 &>/dev/null
|
/etc/stage_flash 3
|
||||||
check_available_space
|
check_available_space
|
||||||
|
|
||||||
# get_ancillary_setup_scripts
|
# get_ancillary_setup_scripts
|
||||||
@@ -258,7 +259,7 @@ echo "" >> /etc/fstab
|
|||||||
|
|
||||||
# SETUP STAGE 4
|
# SETUP STAGE 4
|
||||||
setup_log "SETUP STAGE 4: Create backing files and final config changes."
|
setup_log "SETUP STAGE 4: Create backing files and final config changes."
|
||||||
/tmp/stage_flash 4 &>/dev/null
|
/etc/stage_flash 4
|
||||||
|
|
||||||
create_usb_drive_backing_files
|
create_usb_drive_backing_files
|
||||||
|
|
||||||
@@ -271,9 +272,9 @@ configure_hostname
|
|||||||
# SETUP STAGE 5 and reboot
|
# SETUP STAGE 5 and reboot
|
||||||
# If you see 5 flashes we are probably good!
|
# If you see 5 flashes we are probably good!
|
||||||
|
|
||||||
/tmp/stage_flash 5 &>/dev/null
|
/etc/stage_flash 5
|
||||||
mark_setup_success
|
mark_setup_success
|
||||||
|
echo 1 | sudo tee /sys/class/leds/led0/brightness
|
||||||
make_root_fs_readonly
|
make_root_fs_readonly
|
||||||
|
|
||||||
setup_log "Filesystems made read-only. Rebooting."
|
setup_log "Filesystems made read-only. Rebooting."
|
||||||
|
|||||||
Reference in New Issue
Block a user