Last active
September 16, 2019 16:43
-
-
Save pinebright/6041067238de7c9b7f3fc78301af5e7a to your computer and use it in GitHub Desktop.
debian化
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
device=/dev/$(lsblk -lno NAME | sed '/2/!d') | |
targetdir=/mnt/sdcard | |
# mirror=http://ftp.uni-stuttgrat.de/debian | |
distro=jessie | |
rootfsdir=/tmp/rootfs | |
hostname=debian | |
passwd=root | |
timezone=UTC | |
pkg= | |
sudo mkdir -p $rootfsdir | |
sudo rm -rf $rootfsdir/* | |
sudo debootstrap --foreign --arch armhf $distro $rootfsdir | |
sudo cp /usr/bin/qemu-arm-static $rootfsdir/usr/bin | |
sudo cp /etc/resolv.conf $rootfsdir/etc | |
sudo chroot $rootfsdir <<- EOF_CHROOT | |
export LANG=C | |
/debootstrap/debootstrap --second-stage | |
cat <<- EOF_CAT > /etc/apt/sources.list | |
deb http://ftp.jp.debian.org/debian $distro main contrib non-free | |
deb-src http://ftp.jp.debian.org/debian $distro main contrib non-free | |
deb http://ftp.debian.org/debian $distro-updates main contrib non-free | |
deb-src http://ftp.debian.org/debian $distro-updates main contrib non-free | |
deb http://security.debian.org/debian-security $distro/updates main contrib non-free | |
deb-src http://security.debian.org/debian-security $distro/updates main contrib non-free | |
EOF_CAT | |
cat <<- EOF_CAT > /etc/apt/apt.conf.d/71norecommends | |
APT::Install-Recommends "0"; | |
APT::Install-Suggests "0"; | |
EOF_CAT | |
cat <<- EOF_CAT > /etc/fstab | |
# /etc/fstab: static file system information. | |
# <file system> <mount point> <type> <options> <dump> <pass> | |
/dev/mmcblk0p2 / ext4 errors=remount-ro 0 1 | |
/dev/mmcblk0p1 /boot vfat defaults 0 2 | |
EOF_CAT | |
cat <<- EOF_CAT >> /etc/securetty | |
EOF_CAT | |
echo $hostname > /etc/hostname | |
apt-get update | |
apt-get -y upgrade | |
echo $timezone > /etc/timezone | |
dpkg-reconfigure --frontend=noninteractive tzdata | |
apt-get -y install openssh-server $pkg | |
sed -i 's/^PermitRootLogin.*/PermitRootLogin yes/' /etc/ssh/sshd_config | |
apt-get clean | |
echo root:$passwd | chpasswd | |
history -c | |
EOF_CHROOT | |
sudo rm -f $rootfsdir/etc/resolv.conf | |
sudo rm -f $rootfsdir/usr.bin/qemu-arm-static | |
if [ "$device" != "/dev/" ]; then | |
sudo mkdir -p $targetdir | |
sudo mount "$device" $targetdir | |
sudo rm -rf $targetdir/* | |
sudo cp -a $rootfsdir/* $targetdir | |
sudo umount $targetdir | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment