This repository has been archived by the owner on Sep 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathcustomize-mounted-rootfs.sh
executable file
·79 lines (65 loc) · 2.44 KB
/
customize-mounted-rootfs.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/bin/bash
set -x
SCRIPT_DIR=${SCRIPT_DIR:-`pwd`}
. ${SCRIPT_DIR}/lib.sh
MNT_ROOTFS_DIR=${1:-"/mnt"}
ROOTFS_CUSTOM_DIR=${2:-"${SCRIPT_DIR}/custom/rootfs"}
test -d "${MNT_ROOTFS_DIR}" || f_logAndExit "NO_MOUNTED_ROOTFS_DIR" 1
test -d "${ROOTFS_CUSTOM_DIR}" || f_logAndExit "NO_ROOTFS_CUSTOM_DIR" 1
f_logINFO "Customizing rootfs ..."
cd "${MNT_ROOTFS_DIR}"
cp /usr/bin/qemu-arm-static usr/bin/
# Setup network settings properly
mv etc/resolv.conf etc/resolv.conf.saved
cp /etc/resolv.conf etc/resolv.conf
rsync --ignore-times -rv --chmod=ugo=rwX "${ROOTFS_CUSTOM_DIR}/" "${MNT_ROOTFS_DIR}"
# Mount sys, proc and dev
for m in `echo 'sys dev proc'`; do sudo mount /$m ./$m -o bind; done
# chroot into your target filesystem
sudo LC_ALL=C chroot . /bin/bash -x <<'EOF'
USER_ADMIN_LOGIN=administrator""
USER_ADMIN_FULLNAME="Administrator"
# Install custom startup scripts
chmod +x /etc/init.d/cubian-*
update-rc.d cubian-firstrun defaults
# Get and install some packages
apt-get update
#apt-get -y install vim wireless-tools wpasupplicant hwinfo
apt-get -y install locales
dpkg-reconfigure locales
export LANG=en_US.UTF-8
apt-get -y install openssh-server openssh-client vim wireless-tools wpasupplicant hwinfo
apt-get -y install rsync duplicity
apt-get -y install cpufrequtils
apt-get -y install man
apt-get -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" -y install ntp
apt-get -y install udev
apt-get -y install tree
apt-get -y install hddtemp
apt-get -y install insserv # for cubian* init scripts
apt-get -y install resolvconf iputils-ping iproute
apt-get -y install usbutils
apt-get -y install ca-certificates
apt-get -y install parted
apt-get -y install ifenslave # NIC bonding
# Set timezone
mv -v etc/localtime etc/localtime.bkp
#ln -s /usr/share/zoneinfo/Asia/Taipei /etc/localtime
ln -s /usr/share/zoneinfo/Europe/Paris /etc/localtime
# Add user
useradd -s "/bin/bash" -U -m --comment "${USER_ADMIN_FULLNAME}" --expiredate "" --inactive "-1" "${USER_ADMIN_LOGIN}"
echo "${USER_ADMIN_LOGIN}:admin"|chpasswd
adduser "${USER_ADMIN_LOGIN}" adm
adduser "${USER_ADMIN_LOGIN}" dialout
adduser "${USER_ADMIN_LOGIN}" cdrom
adduser "${USER_ADMIN_LOGIN}" audio
adduser "${USER_ADMIN_LOGIN}" dip
adduser "${USER_ADMIN_LOGIN}" video
adduser "${USER_ADMIN_LOGIN}" plugdev
adduser "${USER_ADMIN_LOGIN}" admin
EOF
# Quit chroot
for m in `echo 'sys dev proc'`; do sudo umount ./$m; done
mv etc/resolv.conf.saved etc/resolv.conf
rm -vf etc/apt/apt.conf.d/01proxy
cd -