User:Mattx86/Alpine Fresh Installation: Difference between revisions

From Alpine Linux
(Created page with "{{Note|This probably needs to be updated, but it's still a useful reference. -- 22:31, 31 October 2010}} The following is a template that I use to quickly setup a fresh install ...")
 
No edit summary
 
Line 1: Line 1:
{{Note|This probably needs to be updated, but it's still a useful reference. -- 22:31, 31 October 2010}}
{{Note|This probably needs to be updated, but it's still a useful reference. -- 22:36, 31 October 2010 (UTC)}}


The following is a template that I use to quickly setup a fresh install of Alpine Linux. Later on, it will be used as the basis for unattended installs of Alpine Linux.
The following is a template that I use to quickly setup a fresh install of Alpine Linux. Later on, it will be used as the basis for unattended installs of Alpine Linux.

Latest revision as of 17:58, 31 October 2010

Note: This probably needs to be updated, but it's still a useful reference. -- 22:36, 31 October 2010 (UTC)

The following is a template that I use to quickly setup a fresh install of Alpine Linux. Later on, it will be used as the basis for unattended installs of Alpine Linux.

Directions:

  1. Start out by creating a new file called myconf.sh on your workstation.
  2. Fill it with the following shell script, review it, and modify it accordingly.
  3. Boot up the Alpine Linux CD/ISO.
  4. Run 'setup-disk' and reboot into the newly installed system.
  5. Get myconf.sh onto the new system (e.g. by local networking or a USB stick).
  6. As root, do: chmod +x myconf.sh && ./myconf.sh
  7. Stick around for prompts.
#!/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