Created
February 10, 2012 06:12
-
-
Save vena/1787125 to your computer and use it in GitHub Desktop.
media server live-build
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 | |
# Install into config/chroot_local-hooks | |
# chmod +x | |
export bold=`tput bold` | |
export normal=`tput sgr0` | |
echo "----------------------------------------------------------" | |
echo "----------------------------------------------------------" | |
echo "\n" | |
echo "${bold}I${normal}: Media Server Install Script ACTIVATE!\n" | |
get_server_name() { | |
read -p "Please enter the ${bold}server's name${normal}: " SERVER_NAME | |
if [ -z "${SERVER_NAME}" ]; then | |
echo "You must provide a name!" | |
get_server_name | |
return 0 | |
fi | |
export SERVER_NAME | |
} | |
get_account_name() { | |
read -p "Please enter the ${bold}account name${normal} to create: " NONLOGIN_USER | |
if [ -z "${NONLOGIN_USER}" ]; then | |
echo "You must supply a user name!" | |
get_account_name | |
return 0 | |
fi | |
export NONLOGIN_USER | |
} | |
get_group_name() { | |
read -p "Please enter the ${bold}group${normal} to create: " NONLOGIN_GROUP | |
if [ -z "${NONLOGIN_GROUP}" ]; then | |
echo "You must supply a group name!" | |
get_group_name | |
return 0 | |
fi | |
export NONLOGIN_GROUP | |
} | |
get_vars() { | |
get_server_name | |
echo "\n" | |
echo "During the install, a non-login user will be set up." | |
echo "This account will be used by greyhole to access Samba," | |
echo "and will also be the account under which SickBeard and" | |
echo "SABnzbd+ should run.\n" | |
get_account_name | |
get_group_name | |
echo "\n" | |
echo "Please look over your entries and confirm:\n" | |
echo "Server Name: ${bold}${SERVER_NAME}${normal}" | |
echo "Non-login User Name: ${bold}${NONLOGIN_USER}${normal}" | |
echo "Non-login Group Name: ${bold}${NONLOGIN_GROUP}${normal}" | |
echo "\n" | |
while true; do | |
read -p "Is this correct? " yn | |
case $yn in | |
[Yy]* ) break;; | |
[Nn]* ) get_vars | |
return 1;; | |
* ) echo "Please enter ${bold}yes${normal} or ${bold}no${normal}.";; | |
esac | |
done | |
} | |
get_vars | |
NONLOGIN_SMBPASSWORD=`</dev/urandom tr -dc A-Za-z0-9 | head -c32` | |
echo "${bold}I${normal}: Creating storage directory" | |
mkdir /storage | |
if [ -f /usr/share/initramfs-tools/scripts/casper-bottom/12fstab ] | |
then | |
echo "${bold}I${normal}: Disabling fstab overwrite (Ubuntu)" | |
chmod -x /usr/share/initramfs-tools/scripts/casper-bottom/12fstab | |
fi | |
if [ -f /etc/init.d/checkfs.sh ] | |
then | |
echo "${bold}I${normal}: Disabling fsck skip (Debian)" | |
sed -i 's/\[ "\$fscheck" = yes ] && log_warning_msg "Fast boot enabled/#\0/;s/fscheck="no"/#\0/' /etc/init.d/checkfs.sh | |
fi | |
echo "${bold}I${normal}: Setting Time Zone" | |
echo "America/New_York" | tee /etc/timezone | |
dpkg-reconfigure --frontend noninteractive tzdata | |
echo "${bold}I${normal}: Reconfiguring .bashrc" | |
sed -i 's/#force_color_prompt=yes/force_color_prompt=yes/;s/#alias /alias /' /etc/skel/.bashrc | |
sed -i 's/#force_color_prompt=yes/force_color_prompt=yes/;s/#alias /alias /' /root/.bashrc | |
#--------------------------------------------------------- | |
# Set up rc.local | |
#--------------------------------------------------------- | |
echo "${bold}I${normal}: Setting up rc.local" | |
sed -i 's/^exit 0//' /etc/rc.local | |
cat << EOF >> /etc/rc.local | |
BOOTDISK=\`readlink /dev/disk/by-label/live | sed -r 's/.*\/([A-Za-z]*).*/\1/'\` | |
echo noop > /sys/block/\${BOOTDISK}/queue/scheduler | |
sysctl -w vm.swappiness=1 | |
sysctl -w vm.vfs_cache_pressure=50 | |
for i in \`find /sys/bus/usb/devices/*/power/{level,control}\`; do echo on > \$i; | |
done; | |
exit 0 | |
EOF | |
#--------------------------------------------------------- | |
# Set up unattended upgrades | |
#--------------------------------------------------------- | |
echo "${bold}I${normal}: Setting up unattended upgrades" | |
cat << EOF > /etc/apt/apt.conf.d/20auto-upgrades | |
APT::Periodic::Update-Package-Lists "1"; | |
APT::Periodic::Unattended-Upgrade "1"; | |
APT::Periodic::Download-Upgradeable-Packages "1"; | |
APT::Periodic::AutocleanInterval "5"; | |
EOF | |
#--------------------------------------------------------- | |
# Fix terminfo issue with aee | |
#--------------------------------------------------------- | |
echo "${bold}I${normal}: Fixing terminfo issue with aee" | |
ln -s /lib/terminfo /usr/lib/terminfo | |
#--------------------------------------------------------- | |
# Set up ssh | |
#--------------------------------------------------------- | |
echo "${bold}I${normal}: Setting up ssh" | |
sed -i 's/PermitRootLogin yes/PermitRootLogin no/;s/#ListenAddress 0/ListenAddress 0/' /etc/ssh/sshd_config | |
#--------------------------------------------------------- | |
# Set up samba | |
#--------------------------------------------------------- | |
echo "${bold}I${normal}: Setting up samba" | |
cp /etc/samba/smb.conf /etc/samba/smb.conf.default | |
cat << EOF > /etc/samba/smb.conf | |
[global] | |
display charset = UTF-8 | |
unix charset = UTF-8 | |
server string = %h (SMB) | |
map to guest = Bad User | |
obey pam restrictions = Yes | |
pam password change = Yes | |
passwd program = /usr/bin/passwd %u | |
passwd chat = *Enter\snew\s*password:* %n\n *Retype\snew\s*password:* %n\n *Password\supdated\ssuccessfully* . | |
unix password sync = Yes | |
syslog = 0 | |
log file = /var/log/samba/%m.log | |
max log size = 1024 | |
socket options = TCP_NODELAY SO_KEEPALIVE SO_RCVBUF=8192 SO_SNDBUF=8192 | |
printcap name = /dev/null | |
load printers = No | |
printing = none | |
disable spoolss = Yes | |
show add printer wizard = No | |
dns proxy = No | |
usershare allow guests = Yes | |
panic action = /usr/share/samba/panic-action %d | |
wide links = yes | |
unix extensions = No | |
include = /etc/samba/greyhole-shares.conf | |
EOF | |
cat << EOF > /etc/samba/greyhole-shares.conf | |
# Example include: | |
# [sharename] | |
# path = /path/to/share | |
# include = /etc/samba/greyhole-include.conf | |
EOF | |
cat <<EOF > /etc/samba/greyhole-include.conf | |
dfree command = /usr/bin/greyhole-dfree | |
vfs objects = greyhole | |
force group = sambashare | |
create mask = 0770 | |
directory mask = 0770 | |
hide unreadable = Yes | |
hide dot files = No | |
EOF | |
echo "${bold}I${normal}: Installing init script to mount SMB shares locally." | |
curl -o /etc/init/mount-smb-locally.conf https://raw.github.com/gist/1713574 | |
sed -i "s/env USER=.*/env USER=${NONLOGIN_USER}/;s/env SMB_CREDENTIALS=.*/env SMB_CREDENTIALS=\/home\/${NONLOGIN_USER}\/.smb_credentials/" /etc/init/mount-smb-locally.conf | |
#--------------------------------------------------------- | |
# Set up netatalk | |
#--------------------------------------------------------- | |
echo "${bold}I${normal}: Setting up netatalk" | |
echo '- -transall -uamlist uams_randnum.so,uams_dhx.so -nosavepassword -advertise_ssh' >> /etc/netatalk/afpd.conf | |
echo '/storage "Storage" allow:@sambashare options:usedots,upriv' > /etc/netatalk/AppleVolumes.default | |
#--------------------------------------------------------- | |
# Set up avahi | |
#--------------------------------------------------------- | |
echo "${bold}I${normal}: Setting up avahi" | |
sed -i 's/hosts:.*/\0 mdns/' /etc/nsswitch.conf | |
cat << EOF > /etc/avahi/services/afpd.service | |
<?xml version="1.0" standalone="no"?><!--*-nxml-*--> | |
<!DOCTYPE service-group SYSTEM "avahi-service.dtd"> | |
<service-group> | |
<name replace-wildcards="yes">%h</name> | |
<service> | |
<type>_afpovertcp._tcp</type> | |
<port>548</port> | |
</service> | |
<service> | |
<type>_device-info._tcp</type> | |
<port>0</port> | |
<txt-record>model=Xserve</txt-record> | |
</service> | |
</service-group> | |
EOF | |
#--------------------------------------------------------- | |
# Set up non-login user account | |
#--------------------------------------------------------- | |
echo "${bold}I${normal}: Setting up non-login user account" | |
addgroup --gid 500 ${NONLOGIN_GROUP} | |
adduser --quiet --uid 500 --gid 500 --shell /usr/sbin/nologin --disabled-password -gecos "" ${NONLOGIN_USER} | |
usermod -a -G sambashare ${NONLOGIN_USER} | |
(echo ${NONLOGIN_SMBPASSWORD}; echo ${NONLOGIN_SMBPASSWORD}) | smbpasswd -a -s ${NONLOGIN_USER} | |
cat << EOF > /home/${NONLOGIN_USER}/.smb_credentials | |
username=${NONLOGIN_USER} | |
password=${NONLOGIN_SMBPASSWORD} | |
EOF | |
chown ${NONLOGIN_USER} /home/${NONLOGIN_USER}/.smb_credentials | |
chmod 0600 /home/${NONLOGIN_USER}/.smb_credentials | |
#--------------------------------------------------------- | |
# Add additional repos | |
#--------------------------------------------------------- | |
echo "${bold}I${normal}: Adding additional repos for post-install config" | |
echo 'deb http://www.greyhole.net/releases/deb stable main' > /etc/apt/sources.list.d/greyhole.list | |
curl -s http://www.greyhole.net/releases/deb/greyhole-debsig.asc | apt-key add - | |
echo 'deb http://www.plexapp.com/repo lucid main' > /etc/apt/sources.list.d/plexmediaserver.list | |
add-apt-repository ppa:jcfp/ppa | |
add-apt-repository ppa:stedy6/stedy-minidna | |
echo "${bold}I${normal}: Config hook setup complete" | |
exit 0 |
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
USERNAME="whatevs" | |
USERFULLNAME="Media Server live user" | |
HOST="yourhost" | |
BUILD_SYSTEM="Ubuntu" |
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 | |
# | |
# For some reason, this can't be run from a hook. The resulting system fails to boot. | |
# You have to manually run it before you exit the chroot. | |
# | |
# REMEMBER TO CHMOD +x THIS | |
echo "Updating initramfs..." | |
for KERNEL in /boot/vmlinuz-* | |
do | |
VERSION="$(basename ${KERNEL} | sed -e 's|vmlinuz-||')" | |
update-initramfs -k ${VERSION} -t -u | |
done | |
echo "Type 'exit' to leave chroot" |
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
ubuntu-minimal | |
ubuntu-standard | |
openssh-server^ | |
curl | |
python-software-properties | |
unattended-upgrades | |
ntp | |
ntpdate | |
netatalk | |
avahi-daemon | |
avahi-utils | |
aee | |
samba | |
lm-sensors | |
hddtemp | |
bindfs | |
git-core |
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
lb config \ | |
--mode ubuntu \ | |
--distribution lucid \ | |
--binary-images iso \ | |
--linux-flavours server \ | |
--bootloader grub2 \ | |
--bootappend-live "persistent toram noprompt vga=789" \ | |
--memtest memtest86+ \ | |
--mirror-bootstrap http://us.archive.ubuntu.com/ubuntu/ \ | |
--mirror-binary http://us.archive.ubuntu.com/ubuntu/ \ | |
--mirror-chroot http://us.archive.ubuntu.com/ubuntu/ \ | |
--archive-areas "main restricted universe multiverse" \ | |
--interactive shell |
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
default=0 | |
timeout=3 | |
insmod vbe | |
insmod font | |
if loadfont /boot/grub/unicode.pf2 | |
then | |
set gfxmode=800x600@32 | |
insmod gfxterm | |
set gfxpayload=keep | |
if terminal_output gfxterm ; true ; else | |
terminal gfxterm | |
fi | |
fi | |
set color_normal=light-gray/dark-gray | |
set menu_color_normal=light-green/green | |
set menu_color_highlight=white/green | |
LINUX_LIVE | |
LINUX_INSTALL | |
MEMTEST |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment