2023-04-08 21:17:31 -04:00

38 lines
1.1 KiB
Bash
Executable File

#!/bin/sh
set -e # Exit immediately if a command exits with a non-zero status.
set -u # Treat unset variables as an error.
# Make sure some directories are created.
mkdir -p /config/downloads
mkdir -p /config/log/firefox
mkdir -p /config/profile
# Generate machine id.
if [ ! -f /config/machine-id ]; then
echo "generating machine-id..."
cat /proc/sys/kernel/random/uuid | tr -d '-' > /config/machine-id
fi
# Copy default preferences.
[ -f /config/profile/prefs.js ] || cp /defaults/prefs.js /config/profile/prefs.js
# Clean/optimize Firefox databases.
#if [ -d /config/.mozilla/firefox ] && [ -d /config/profile ]; then
# [ -f /config/.mozilla/firefox/profiles.ini ] || cp /defaults/profiles.ini /config/.mozilla/firefox/
# env HOME=/config /usr/bin/profile-cleaner f
#fi
# Initialize log files.
for LOG_FILE in /config/log/firefox/output.log /config/log/firefox/error.log
do
touch "$LOG_FILE"
# Make sure the file doesn't grow indefinitely.
if [ "$(stat -c %s "$LOG_FILE")" -gt 1048576 ]; then
echo > "$LOG_FILE"
fi
done
# vim:ft=sh:ts=4:sw=4:et:sts=4