2020-05-06 11:40:06 -04:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
2020-06-17 12:20:28 -04:00
|
|
|
wheel_gid=1
|
2020-05-06 11:40:06 -04:00
|
|
|
phys_gid=3
|
2020-09-06 10:10:27 -04:00
|
|
|
utmp_gid=5
|
2020-05-06 11:40:06 -04:00
|
|
|
window_uid=13
|
|
|
|
window_gid=13
|
|
|
|
|
2020-09-20 15:34:14 -04:00
|
|
|
CP="cp"
|
|
|
|
|
2020-10-17 16:25:13 -04:00
|
|
|
# cp on macOS and BSD systems do not support the -d option.
|
2020-09-20 15:34:14 -04:00
|
|
|
# gcp comes with coreutils, which is already a dependency.
|
2020-10-17 16:25:13 -04:00
|
|
|
OS="$(uname -s)"
|
|
|
|
if [ "$OS" = "Darwin" ] || echo "$OS" | grep -qe 'BSD$'; then
|
|
|
|
CP="gcp"
|
2020-09-20 15:34:14 -04:00
|
|
|
fi
|
|
|
|
|
2020-05-06 11:40:06 -04:00
|
|
|
die() {
|
|
|
|
echo "die: $*"
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
if [ "$(id -u)" != 0 ]; then
|
|
|
|
die "this script needs to run as root"
|
|
|
|
fi
|
|
|
|
|
|
|
|
[ -z "$SERENITY_ROOT" ] && die "SERENITY_ROOT is not set"
|
|
|
|
[ -d "$SERENITY_ROOT/Base" ] || die "$SERENITY_ROOT/Base doesn't exist"
|
|
|
|
|
|
|
|
umask 0022
|
|
|
|
|
2020-06-04 18:38:42 -04:00
|
|
|
printf "installing base system... "
|
2020-09-20 15:34:14 -04:00
|
|
|
$CP -PdR "$SERENITY_ROOT"/Base/* mnt/
|
2020-12-28 22:38:52 -05:00
|
|
|
$CP "$SERENITY_ROOT"/Toolchain/Local/i686/i686-pc-serenity/lib/libgcc_s.so mnt/usr/lib/
|
2020-09-20 15:34:14 -04:00
|
|
|
$CP -PdR Root/* mnt/
|
2020-06-04 18:39:53 -04:00
|
|
|
# If umask was 027 or similar when the repo was cloned,
|
|
|
|
# file permissions in Base/ are too restrictive. Restore
|
|
|
|
# the permissions needed in the image.
|
|
|
|
chmod -R g+rX,o+rX "$SERENITY_ROOT"/Base/* mnt/
|
2020-06-04 18:38:42 -04:00
|
|
|
|
|
|
|
chmod 660 mnt/etc/WindowServer/WindowServer.ini
|
|
|
|
chown $window_uid:$window_gid mnt/etc/WindowServer/WindowServer.ini
|
|
|
|
echo "/bin/sh" > mnt/etc/shells
|
|
|
|
|
2020-06-17 12:20:28 -04:00
|
|
|
chown 0:$wheel_gid mnt/bin/su
|
2020-07-25 18:08:55 -04:00
|
|
|
chown 0:$wheel_gid mnt/bin/passwd
|
2020-06-18 16:19:57 -04:00
|
|
|
chown 0:$phys_gid mnt/bin/keymap
|
2020-06-04 18:38:42 -04:00
|
|
|
chown 0:$phys_gid mnt/bin/shutdown
|
|
|
|
chown 0:$phys_gid mnt/bin/reboot
|
|
|
|
chown 0:0 mnt/boot/Kernel
|
|
|
|
chown 0:0 mnt/res/kernel.map
|
|
|
|
chmod 0400 mnt/res/kernel.map
|
|
|
|
chmod 0400 mnt/boot/Kernel
|
|
|
|
chmod 4750 mnt/bin/su
|
2020-07-25 18:08:55 -04:00
|
|
|
chmod 4755 mnt/bin/passwd
|
2020-06-04 18:38:42 -04:00
|
|
|
chmod 4755 mnt/bin/ping
|
|
|
|
chmod 4750 mnt/bin/reboot
|
|
|
|
chmod 4750 mnt/bin/shutdown
|
2020-06-18 16:19:57 -04:00
|
|
|
chmod 4750 mnt/bin/keymap
|
2020-09-06 10:10:27 -04:00
|
|
|
chown 0:$utmp_gid mnt/bin/utmpupdate
|
|
|
|
chmod 2755 mnt/bin/utmpupdate
|
2021-01-09 11:44:44 -05:00
|
|
|
chmod 600 mnt/etc/shadow
|
2020-06-04 18:38:42 -04:00
|
|
|
echo "done"
|
|
|
|
|
2020-05-06 11:40:06 -04:00
|
|
|
printf "creating initial filesystem structure... "
|
2020-09-06 10:10:27 -04:00
|
|
|
for dir in bin etc proc mnt tmp boot mod var/run; do
|
2020-05-06 11:40:06 -04:00
|
|
|
mkdir -p mnt/$dir
|
|
|
|
done
|
|
|
|
chmod 700 mnt/boot
|
|
|
|
chmod 700 mnt/mod
|
|
|
|
chmod 1777 mnt/tmp
|
|
|
|
echo "done"
|
|
|
|
|
2020-09-06 10:10:27 -04:00
|
|
|
printf "creating utmp file... "
|
|
|
|
touch mnt/var/run/utmp
|
|
|
|
chown 0:$utmp_gid mnt/var/run/utmp
|
|
|
|
chmod 664 mnt/var/run/utmp
|
|
|
|
echo "done"
|
|
|
|
|
2020-12-25 12:26:38 -05:00
|
|
|
printf "setting up device nodes folder... "
|
2020-05-06 11:40:06 -04:00
|
|
|
mkdir -p mnt/dev
|
2021-01-16 12:37:03 -05:00
|
|
|
echo "done"
|
2020-05-06 11:40:06 -04:00
|
|
|
|
2020-05-24 10:26:33 -04:00
|
|
|
printf "writing version file... "
|
|
|
|
GIT_HASH=$( (git log --pretty=format:'%h' -n 1 | head -c 7) || true )
|
|
|
|
printf "[Version]\nMajor=1\nMinor=0\nGit=%s\n" "$GIT_HASH" > mnt/res/version.ini
|
|
|
|
echo "done"
|
|
|
|
|
2020-05-06 11:40:06 -04:00
|
|
|
printf "installing users... "
|
|
|
|
mkdir -p mnt/root
|
|
|
|
mkdir -p mnt/home/anon
|
|
|
|
mkdir -p mnt/home/anon/Desktop
|
|
|
|
mkdir -p mnt/home/anon/Downloads
|
|
|
|
mkdir -p mnt/home/nona
|
|
|
|
cp "$SERENITY_ROOT"/ReadMe.md mnt/home/anon/
|
2021-01-12 06:17:30 -05:00
|
|
|
cp -r "$SERENITY_ROOT"/Userland/Libraries/LibJS/Tests mnt/home/anon/js-tests
|
|
|
|
cp -r "$SERENITY_ROOT"/Userland/Libraries/LibWeb/Tests mnt/home/anon/web-tests
|
2020-05-06 11:40:06 -04:00
|
|
|
chmod 700 mnt/root
|
|
|
|
chmod 700 mnt/home/anon
|
|
|
|
chmod 700 mnt/home/nona
|
|
|
|
chown -R 0:0 mnt/root
|
|
|
|
chown -R 100:100 mnt/home/anon
|
|
|
|
chown -R 200:200 mnt/home/nona
|
|
|
|
echo "done"
|
|
|
|
|
2020-12-27 08:51:08 -05:00
|
|
|
printf "adding some desktop icons..."
|
|
|
|
ln -s /bin/Browser mnt/home/anon/Desktop/
|
|
|
|
ln -s /bin/TextEditor mnt/home/anon/Desktop/
|
|
|
|
ln -s /bin/Help mnt/home/anon/Desktop/
|
2021-01-21 16:56:28 -05:00
|
|
|
ln -s /home/anon mnt/home/anon/Desktop/Home
|
|
|
|
echo "done"
|
2020-12-27 08:51:08 -05:00
|
|
|
|
2020-05-06 11:40:06 -04:00
|
|
|
printf "installing shortcuts... "
|
|
|
|
ln -s Shell mnt/bin/sh
|
2020-06-23 23:57:00 -04:00
|
|
|
ln -s test mnt/bin/[
|
2020-05-06 11:40:06 -04:00
|
|
|
echo "done"
|
|
|
|
|
2020-09-12 14:37:12 -04:00
|
|
|
printf "installing 'checksum' variants... "
|
|
|
|
ln -s checksum mnt/bin/md5sum
|
|
|
|
ln -s checksum mnt/bin/sha1sum
|
|
|
|
ln -s checksum mnt/bin/sha256sum
|
|
|
|
ln -s checksum mnt/bin/sha512sum
|
|
|
|
echo "done"
|
|
|
|
|
2021-01-29 18:24:54 -05:00
|
|
|
if [ -f "${SERENITY_ROOT}/Kernel/sync-local.sh" ] || [ -f "${SERENITY_ROOT}/Build/sync-local.sh" ]; then
|
|
|
|
# TODO: Deprecated on 2021-01-30. In a few months, remove this 'if'.
|
|
|
|
tput setaf 1
|
|
|
|
echo
|
|
|
|
echo " +-----------------------------------------------------------------------------+"
|
|
|
|
echo " | |"
|
|
|
|
echo " | WARNING: sync-local.sh, previously located in Kernel/ and later Build/ |"
|
|
|
|
echo " | must be moved to \$SERENITY_ROOT! |"
|
|
|
|
echo " | See https://github.com/SerenityOS/serenity/pull/5172 for details. |"
|
|
|
|
echo " | |"
|
|
|
|
echo " +-----------------------------------------------------------------------------+"
|
|
|
|
echo
|
|
|
|
tput sgr 0
|
|
|
|
fi
|
|
|
|
|
2020-05-06 11:40:06 -04:00
|
|
|
# Run local sync script, if it exists
|
2021-01-30 14:47:13 -05:00
|
|
|
if [ -f "${SERENITY_ROOT}/sync-local.sh" ]; then
|
2021-01-29 18:24:54 -05:00
|
|
|
sh "${SERENITY_ROOT}/sync-local.sh"
|
2020-05-06 11:40:06 -04:00
|
|
|
fi
|