用户:Mattx86/Alpine全新安装
注意: 这可能需要更新,但仍然是一个有用的参考。 -- 22:36, 2010年10月31日 (UTC)
以下是我用来快速设置Alpine Linux全新安装的模板。之后,它将被用作Alpine Linux无人值守安装的基础。
说明
- 首先,在您的工作站上创建一个名为
myconf.sh
的新文件。 - 将以下 shell 脚本填充到文件中,检查它,并进行相应的修改。
- 启动 Alpine Linux CD/ISO。
- 运行 'setup-disk' 并重启进入新安装的系统。
- 将
myconf.sh
放到新系统上 (例如,通过本地网络或 USB 驱动器)。 - 以 root 用户身份执行:
chmod +x myconf.sh && ./myconf.sh
- 留意提示。
#!/bin/sh # Change root password ### NOTE: As is, this will prompt for a password. ### Marked for a later update geared towards an unattended install. passwd # Setup Hostname echo "alpinevm.lan" > /etc/hostname echo -en "127.0.0.1\tlocalhost.localdomain\tlocalhost\n" > /etc/hosts echo -en "::1\tlocalhost.localdomain\tlocalhost\tipv6-localhost\tipv6-loopback\n" >> /etc/hosts echo -en "10.0.0.2\talpinevm.lan\talpinevm\n" >> /etc/hosts echo -en "2001:470:ffff:ff::2\talpinevm.lan\talpinevm\n" >> /etc/hosts hostname -F /etc/hostname # IPv4 and IPv6 Configuration for eth0 echo -en "auto lo\n\ iface lo inet loopback\n\ \n\ auto eth0\n\ iface eth0 inet static\n\ address 10.0.0.2\n\ netmask 255.255.255.0\n\ gateway 10.0.0.1\n\ \n\ iface eth0 inet6 static\n\ address 2001:470:ffff:ff::2\n\ netmask 64\n\ gateway 2001:470:ffff:ff::1\n" > /etc/network/interfaces chown root:root /etc/network/interfaces chmod 644 /etc/network/interfaces # Name Server Configuration echo "nameserver 8.8.8.8" > /etc/resolv.conf echo "nameserver 8.8.4.4" >> /etc/resolv.conf # Configure IPv6 module to load on boot, and load it now. echo "ipv6" >> /etc/modules modprobe ipv6 # Bring up networking /etc/init.d/networking restart # Add acpid and cron to startup, and start them up. rc-update -q add acpid rc-update -q add cron /etc/init.d/acpid restart /etc/init.d/cron restart # Configure apk repositories echo "http://dl-4.alpinelinux.org/alpine/v2.0/packages/main/" > /etc/apk/repositories echo "http://dl-4.alpinelinux.org/alpine/v2.0/packages/testing/" >> /etc/apk/repositories # Update apk package list and upgrade system. apk update apk upgrade # Install the software we need apk add bkeymaps openssh bash nano iputils ircii alpine-sdk # Setup Keymap (requires package bkeymaps) ### NOTE: Marked for a later update geared towards an unattended install. /sbin/setup-keymap # Change root's shell to bash sed -ri 's;^(root:x:0:0:root:/root:)/bin/sh;\1/bin/bash;' /etc/passwd # Add user account addgroup newuser adduser -s /bin/bash -G newuser newuser ### NOTE: As is, this will prompt for a password. ### Marked for a later update geared towards an unattended install. # Configure the new account for sudo sed -ri 's/(wheel:x:10:root)/\1,newuser/' /etc/group sed -ri 's/# %wheel\tALL=\(ALL\) ALL/%wheel\tALL=\(ALL\) ALL/' /etc/sudoers # Configure the new account for git su -s /bin/bash -c "git config --global user.name \"Your Full Name\"" newuser su -s /bin/bash -c "git config --global user.email \"your@email.address\"" newuser # Clone aports tree git clone git://git.alpinelinux.org/aports /usr/aports chown -R root:wheel /usr/aports chmod -R 774 /usr/aports # Configure abuild.conf and generate security keys for abuild sed -i 's/#PACKAGER="Your Name <your@email.address>"/PACKAGER="Your Name <your@email.address>"/' /etc/abuild.conf su -s /bin/bash -c "abuild-keygen -a -i" newuser ### NOTE: This will prompt for a location to save the key and the user's password. ### Marked for a later update geared towards an unattended install. # Configure openssh to start on boot, allow root access, turn off DNS usage, and start it up. rc-update add sshd sed -i 's/^#PermitRootLogin.*/PermitRootLogin yes/' /etc/ssh/sshd_config sed -i 's/^#UseDNS.*/UseDNS no/' /etc/ssh/sshd_config /etc/init.d/sshd restart # Exit and log back in for bash. echo "Log back in for bash." exit