~j-harbott/cirros/dev

18 by Scott Moser
add perms.list and fixups.list from ttylinux-uec
1
#!/bin/sh
144 by Scott Moser
use /run, and move man symlinks to /tmp from /var/
2
error() { echo "$@" 1>&2; }
3
fail() { [ $# -eq 0 ] || error "$@"; exit 1; }
18 by Scott Moser
add perms.list and fixups.list from ttylinux-uec
4
5
rootd=${1}
6
[ -n "${rootd}" -a -d "${rootd}" ] || exit 1
7
110 by Scott Moser
begin managing the default user's home.
8
rm -Rf "$rootd/home/default"
109 by Scott Moser
enable 'sudo' in config, and set up cirros user to have sudo
9
10
# no need for visudo
11
rm -f "$rootd/usr/sbin/visudo"
144 by Scott Moser
use /run, and move man symlinks to /tmp from /var/
12
13
# buildroot symlinks stuff in /var to /tmp
14
links="lib/pcmcia pcmcia lock cache log spool pcmcia"
247 by Scott Moser
make fixup-fs idempotent
15
for f in $links; do
16
	p="/var/$f"
17
	if [ -L "$rootd/$p" ]; then
18
		rm "$rootd/$p" ||
19
			fail "failed to remove file $p"
20
	elif [ -d "$rootd/$p" ]; then
21
		rmdir "$rootd/$p" ||
22
			fail "rmdir $p failed"
23
	else
24
		[ -e "$rootd/$p" ] &&
25
			fail "don't know what to do with $p. not dir or link"
26
	fi
27
done
28
mkdir -p $rootd/var
29
( cd "$rootd/var" && mkdir -p $links ) ||
30
   fail "failed to create directories in /var"
144 by Scott Moser
use /run, and move man symlinks to /tmp from /var/
31
247 by Scott Moser
make fixup-fs idempotent
32
( cd "$rootd/var" && rm -Rf tmp run &&
144 by Scott Moser
use /run, and move man symlinks to /tmp from /var/
33
   ln -s ../run run && ln -s ../run/var.tmp tmp ) ||
34
   fail "failed to make var/run and var/tmp"
35
247 by Scott Moser
make fixup-fs idempotent
36
rm -f $rootd/etc/resolv.conf &&
144 by Scott Moser
use /run, and move man symlinks to /tmp from /var/
37
   ln -sf ../run/resolv.conf "$rootd/etc/resolv.conf" ||
38
   fail "failed to create resolv.conf symlink"
146 by Scott Moser
remove busybox's blkid program as we have the real thing
39
40
if [ -L "$rootd/sbin/blkid" -a -x "$rootd/usr/sbin/blkid" ]; then
148 by Scott Moser
remove busybox's blkid, not the real one
41
   rm -f "$rootd/sbin/blkid"
146 by Scott Moser
remove busybox's blkid program as we have the real thing
42
fi