Last active
December 28, 2015 20:39
-
-
Save kemadz/7559103 to your computer and use it in GitHub Desktop.
Funtoo Install Script Chroot Part for Virtualbox
This file contains 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 | |
# Funtoo Install Script Chroot Part for Virtualbox | |
# 更新环境变量 | |
source /etc/profile | |
export PS1="(chroot) $PS1" | |
# 设置时区和硬件时钟 | |
echo "-*- locale -*-" | |
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime | |
echo "Asia/Shanghai" > /etc/timezone | |
# 检查时间 | |
date | |
sed -i "/clock=/s/UTC/local/" /etc/conf.d/hwclock | |
# 设置网络 | |
echo "-*- network -*-" | |
ln -sf /etc/init.d/netif.tmpl /etc/init.d/netif.eth0 | |
cat > /etc/conf.d/netif.eth0 <<DELIM | |
template="interface" | |
ipaddr="10.0.2.15/24" | |
gateway="10.0.2.2" | |
nameservers="114.114.114.114" | |
DELIM | |
cat /etc/conf.d/netif.eth0 | |
# 设置主机名 | |
echo "-*- hostname -*-" | |
sed -i "s/localhost/fnto/" /etc/conf.d/hostname | |
# 设置域名服务器,以便同步 portage | |
echo "nameserver 114.114.114.114" > /etc/resolv.conf | |
# 设置文件系统列表 | |
sed -i \ | |
-e '/sda1/s/noatime/noatime\t/' \ | |
-e '/sda1/s/ext2/ext4/' \ | |
-e '/sda4/s/xfs/ext4/' \ | |
/etc/fstab | |
# 本地化,生成字符集 | |
cat > /etc/locale.gen <<DELIM | |
en_US ISO-8859-1 | |
en_US.UTF-8 UTF-8 | |
zh_CN.GB18030 GB18030 | |
zh_CN.GBK GBK | |
zh_CN.UTF-8 UTF-8 | |
zh_CN GB2312 | |
DELIM | |
locale-gen | |
# make.conf | |
cat >> /etc/portage/make.conf <<DELIM | |
MAKEOPTS="-j9" | |
GENTOO_MIRRORS="http://mirrors.ustc.edu.cn/gentoo" | |
# ruby | |
RUBY_TARGETS="ruby22" | |
DELIM | |
# package.mask | |
# cat >> /etc/portage/package.mask <<DELIM | |
# >=sys-apps/texinfo-5.1 | |
# DELIM | |
# 更新 portage | |
cd /usr/portage | |
git checkout funtoo.org | |
emerge --sync | |
# 安装内核 | |
# eselect profile set 2 | |
# emerge gentoo-sources # genkernel | |
# genkernel --menuconfig all | |
# zcat /proc/config.gz > /usr/src/linux/.config | |
# cd /usr/src/linux | |
# make -j4 | |
# make modules_install | |
# cp /usr/src/linux/arch/x86/boot/bzImage /boot/ | |
cp /bzImage /boot/ | |
mkdir -p /lib/modules | |
tar xf /lib.txz -C /lib/modules | |
# 安装必要的软件 | |
emerge eix gentoolkit mutt netkit-telnetd pfl texinfo | |
emerge metalog cronie vim sudo klibc v86d | |
emerge bind-tools nmap tmux | |
# 设置自启动 | |
echo "-*- configuring services -*-" | |
rc-update add netif.eth0 default | |
rc-update add cronie default | |
rc-update add metalog default | |
# 配置修改 | |
sed -i '/rc_sys/s/#rc/rc/' /etc/rc.conf | |
# 安装并配置GRUB引导管理器 | |
echo "-*- grub -*-" | |
emerge boot-update | |
grub-install --no-floppy /dev/sda | |
cat > /etc/boot.conf <<DELIM | |
boot { | |
generate grub | |
default "Funtoo Linux" | |
timeout 3 | |
} | |
display { | |
gfxmode 800x600x32 | |
} | |
"Funtoo Linux" { | |
kernel bzImage | |
params quiet root=/dev/sda4 video=uvesafb:800x600-32,mtrr:3,ywrap | |
} | |
DELIM | |
boot-update | |
# 添加用户并修改密码 | |
echo "-*- add user -*-" | |
useradd -m -G audio,cdrom,cron,portage,usb,users,video,wheel -s /bin/bash zhong | |
cat >passwd.txt <<DELIM | |
zhong:zhong | |
root:root | |
DELIM | |
chpasswd <passwd.txt | |
rm passwd.txt | |
sed -i "/NOPASSWD/s/# //" /etc/sudoers | |
# 清理安装包并退出chroot | |
rm /*-latest.tar.xz | |
rm /vbox_*.sh | |
rm /bzImage | |
rm /lib.txz | |
exit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment