-
Notifications
You must be signed in to change notification settings - Fork 11
/
2-chroot.sh
executable file
·62 lines (58 loc) · 2.02 KB
/
2-chroot.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
#!/bin/bash
echo "nameserver 223.5.5.5" >> rootfs/etc/resolv.conf
#sed -i "s/ports.ubuntu.com/mirrors.aliyun.com/g" rootfs/etc/apt/sources.list
#echo "hi3798mv100" > rootfs/etc/hostname
echo "127.0.0.1 localhost" > rootfs/etc/hosts
cp -a pre_files/system-init.sh rootfs/etc/init.d
chmod +x rootfs/etc/init.d/system-init.sh
cat << EOF | LC_ALL=C LANGUAGE=C LANG=C chroot rootfs
mknod /dev/console c 5 1
mknod /dev/ttyAMA0 c 204 64
mknod /dev/ttyAMA1 c 204 65
mknod /dev/ttyS000 c 204 64
mknod /dev/null c 1 3
mknod /dev/urandom c 1 9
mknod /dev/zero c 1 5
mknod /dev/random c 1 8
mknod /dev/tty c 5 0
apt-get update
apt-get upgrade -y
apt-get install -y jq ntfs-3g smartmontools usbutils dnsutils network-manager nginx \
locales wget curl vim nfs-kernel-server iputils-ping bash-completion \
ssh net-tools sudo php-fpm php-sqlite3 transmission-daemon libnginx-mod-http-dav-ext \
cron ethtool zip ifupdown htop rsyslog dialog resolvconf aria2 vsftpd
sed -i -e 's/#PasswordAuthentication/PasswordAuthentication/g' /etc/ssh/sshd_config
echo "PermitRootLogin yes" >> /etc/ssh/sshd_config
echo "Asia/Shanghai" > /etc/timezone
cp -a /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
echo "en_US.UTF-8 UTF-8
zh_CN.UTF-8 UTF-8
zh_CN.GB2312 GB2312
zh_CN.GBK GBK" > /etc/locale.gen
locale-gen
echo "LANG=en_US.UTF-8" > /etc/locale.conf
echo 'LC_CTYPE="en_US.UTF-8"
LC_ALL="en_US.UTF-8"
LANG="en_US.UTF-8"
' > /etc/default/locale
update-rc.d system-init.sh defaults 90
useradd -s '/bin/bash' -m -G adm,sudo ubuntu
gpasswd -a ubuntu sudo
echo -e "1234\n1234\n" | passwd ubuntu
echo -e "1234\n1234\n" | passwd root
echo "www-data ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
visudo -c
apt-get autoremove --purge -y
apt-get autoclean -y
apt-get clean -y
EOF
cat <<EOT >> rootfs/etc/fstab
/swapfile swap swap defaults 0 0
/dev/mmcblk0p6 / ext4 defaults,noatime,errors=remount-ro 0 1
EOT
mkdir -p rootfs/etc/network/interfaces.d
touch -f rootfs/etc/network/interfaces.d/eth0
cat <<EOT >> rootfs/etc/network/interfaces.d/eth0
auto eth0
iface eth0 inet dhcp
EOT