Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 304 lines (266 sloc) 11.5 KB
#!/bin/bash
###################################################################################
# UCK - Ubuntu Customization Kit #
# Copyright (C) 2006-2010 UCK Team #
# #
# UCK is free software: you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation, either version 3 of the License, or #
# (at your option) any later version. #
# #
# UCK is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with UCK. If not, see <http://www.gnu.org/licenses/>. #
###################################################################################
function failure()
{
echo "$@"
exit 1
}
function prepare_install()
{
#Does this work in the chroot or outside of it?
sed -i "s/^# \+\(deb.*universe\)$/\1/" /etc/apt/sources.list
rm -f /etc/apt/sources.list && touch /etc/apt/sources.list
cat << REPOS > /dev/null
deb http://failover.hackbloc.org:9090/ubuntu/ oneiric main restricted
deb http://failover.hackbloc.org:9090/ubuntu/ oneiric-security main restricted
deb http://failover.hackbloc.org:9090/ubuntu/ oneiric-updates main restricted
deb http://failover.hackbloc.org:9090/ubuntu/ oneiric-backports main restricted universe multiverse
deb http://failover.hackbloc.org:9090/ubuntu/ oneiric multiverse
deb http://failover.hackbloc.org:9090/ubuntu/ oneiric universe
deb http://failover.hackbloc.org:9090/ubuntu/ oneiric-updates universe
REPOS
cat << REPOS > /etc/apt/sources.list
deb http://us.archive.ubuntu.com/ubuntu/ oneiric main restricted
deb http://us.archive.ubuntu.com/ubuntu/ oneiric-updates main restricted
deb http://us.archive.ubuntu.com/ubuntu/ oneiric universe
deb http://us.archive.ubuntu.com/ubuntu/ oneiric-updates universe
deb http://us.archive.ubuntu.com/ubuntu/ oneiric multiverse
deb http://us.archive.ubuntu.com/ubuntu/ oneiric-updates multiverse
deb http://us.archive.ubuntu.com/ubuntu/ oneiric-backports main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu oneiric-security main restricted
deb http://security.ubuntu.com/ubuntu oneiric-security universe
deb http://security.ubuntu.com/ubuntu oneiric-security multiverse
deb http://archive.canonical.com/ubuntu oneiric partner
deb http://extras.ubuntu.com/ubuntu oneiric main
REPOS
#try 2 times to avoid slow proxies failures
apt-get update || apt-get update || failure "apt-get update failed, error=$?"
dpkg --configure acpid
dpkg --configure -a
dpkg --configure cups
dpkg --configure -a
dpkg --configure bluez-cups
dpkg --configure -a
dpkg --configure hplip-cups
dpkg --configure -a
dpkg --configure hplip
dpkg --configure -a
apt-get update
apt-get install -f
apt-get upgrade --assume-yes
}
function install_packages()
{
apt-get install --assume-yes --force-yes "$@" || failure "apt-get install $@ failed, error=$?"
}
function remove_packages()
{
apt-get --purge remove --assume-yes --force-yes "$@" || failure "apt-get remove $@ failed, error=$?"
}
function run_package_manager()
{
echo "Starting package application..."
PACKAGE_APP=`which adept`
PACKAGE_APP_OPTIONS=(--caption "UCK Package Manager")
if [ "$PACKAGE_APP" = "" ]; then
PACKAGE_APP=`which adept_manager`
fi
if [ "$PACKAGE_APP" = "" ]; then
PACKAGE_APP=`which synaptic`
PACKAGE_APP_OPTIONS=(-t "UCK Package manager")
fi
if [ "$PACKAGE_APP" = "" ]; then
dialog_msgbox "Failure" "Unable to find any package manager application"
else
$PACKAGE_APP "${PACKAGE_APP_OPTIONS[@]}"
RESULT=$?
if [ $RESULT -ne 0 ]; then
dialog_msgbox "Failure" "Running package application $PACKAGE_APP failed, error=$RESULT"
fi
fi
}
function run_console()
{
echo "Starting console application..."
CONSOLE_APP=`which konsole`
CONSOLE_APP_OPTIONS=(--caption "UCK customization console" -e /bin/bash)
if [ "$CONSOLE_APP" = "" ]; then
CONSOLE_APP=`which gnome-terminal`
CONSOLE_APP_OPTIONS=(-t "UCK customization console" -e /bin/bash)
fi
if [ "$CONSOLE_APP" = "" ]; then
CONSOLE_APP=`which xfce4-terminal`
CONSOLE_APP_OPTIONS=(-t "UCK customization console" -e /bin/bash)
fi
if [ "$CONSOLE_APP" = "" ]; then
CONSOLE_APP=`which xterm`
CONSOLE_APP_OPTIONS=(-title "UCK customization console" -e /bin/bash)
fi
if [ "$CONSOLE_APP" = "" ]; then
dialog_msgbox "Failure" "Unable to find any console application"
else
eval `dbus-launch --sh-syntax --exit-with-session 2>/dev/null`
$CONSOLE_APP "${CONSOLE_APP_OPTIONS[@]}"
RESULT=$?
if [ $RESULT -ne 0 ]; then
echo "Running console application $CONSOLE_APP failed, trying the fallback xterm"
xterm -title "UCK customization console" -e /bin/bash
RESULT=$?
if [ $RESULT -ne 0 ]; then
dialog_msgbox "Failure" "Running console application $CONSOLE_APP failed, error=$RESULT"
fi
fi
fi
}
SCRIPT_DIR=`dirname "$0"`
LIVECD_LANGS=`cat "$SCRIPT_DIR/language_packs"`
RUN_MANUAL_CUSTOMIZATIONS=`cat "$SCRIPT_DIR/run_manual_customizations"`
DESKTOP_TYPE=`cat "$SCRIPT_DIR/desktop_type"`
DESKTOP_FLAVOURS=`cat "$SCRIPT_DIR/desktop_types"`
# We need to install at least dialog here else the include of gui.sh will fail
echo "---- Preparing to install packages ----"
prepare_install #|| failure "Preparing installation failed, error=$?"
PACKAGES_TO_INSTALL="openssh-server openvpn ekiga libdata-password-perl libemail-valid-perl libnet-dbus-perl perl-modules uck linux-headers-generic lsof dialog"
echo "---- Installing packages: $PACKAGES_TO_INSTALL ----"
install_packages $PACKAGES_TO_INSTALL || failure "Installing language packs failed, error=$?"
. "$SCRIPT_DIR/gui.sh"
echo "Installing language packs ($LIVECD_LANGS)..."
LANGPACKS_CONCATENATED=""
if [ -n "$LIVECD_LANGS" ]; then
for LANGPACK in $LIVECD_LANGS; do
PACKAGES_TO_INSTALL="language-pack-$LANGPACK language-support-$LANGPACK"
if [ "$DESKTOP_FLAVOURS" ]; then
for FLAVOUR in $DESKTOP_FLAVOURS; do
if [ $FLAVOUR == "gnome" ] || [ $FLAVOUR == "kde" ]; then
PACKAGES_TO_INSTALL="language-pack-$FLAVOUR-$LANGPACK"
fi
done
fi
if [ -z "$LANGPACKS_CONCATENATED" ]; then
LANGPACKS_CONCATENATED="$LANGPACK"
else
LANGPACKS_CONCATENATED="$LANGPACKS_CONCATENATED|$LANGPACK"
fi
done
install_packages $PACKAGES_TO_INSTALL || failure "Installing language packs failed, error=$?"
export KVERS=`dpkg -l|grep 'linux-headers-.*-generic' |tail -1|awk '{print $2}'|awk -F'linux-headers-' '{print $2}'`
export DEBIAN_FRONTEND=noninteractive
apt-get install --assume-yes --force-yes -qq asterisk
cpanp -i Asterisk::config
# install webmin
# This is to fix some phantom bug that was discovered when testing this
# process. It turns out that the webmin package will return an error
# if there is already a process listening on port 10000. For some reason
# the webmin miniserv kept getting started though.
PID=`lsof -i:10000|awk '{print $2}'|tail -1`
if [ -n $PID ]; then
kill -9 $PID
fi
wget -O /root/webmin-1.530.deb "http://downloads.sourceforge.net/project/webadmin/webmin/1.530/webmin_1.530_all.deb?r=http%3A%2F%2Fwww.webmin.com%2Fdownload.html&ts=1300131418&use_mirror=iweb"
dpkg -i /root/webmin-1.530.deb
# install any additional dependencies
apt-get -y -f install
/etc/init.d/webmin stop
# install the required webmin modules
wget --no-check-certificate -O /root/openvpn-2.5.1.wbm.gz "https://github.com/downloads/March-hare/Operator-Distribution/openvpn-2.5.1.wbm.gz"
wget --no-check-certificate -O /root/operatordistribution-0.0.2.wbm.gz "https://github.com/downloads/March-hare/Operator-Distribution/operatordistribution-0.0.2.wbm.gz"
perl $SCRIPT_DIR/install-module.pl /root/openvpn-2.5.1.wbm.gz
perl $SCRIPT_DIR/install-module.pl /root/operatordistribution-0.0.2.wbm.gz
rm /root/openvpn-2.5.1.wbm.gz /root/operatordistribution-0.0.2.wbm.gz /root/webmin-1.530.deb
# configure webmin to only listen on local host and not use ssl (avoid
# browser warning)
echo "gotomodule=operatordistribution" >> /etc/webmin/config
sed -i 's/ssl=1/ssl=0/' /etc/webmin/miniserv.conf
grep -q "bind=" /etc/webmin/miniserv.conf
if [ -z $? ] ; then
sed -i 's/bind=.*/bind=127.0.0.1/' /etc/webmin/miniserv.conf
else
echo "bind=127.0.0.1" >> /etc/webmin/miniserv.conf
fi
# Make sure firefox loads on startup with the webmin interface
mkdir -p /etc/skel/.config/autostart
cat <<-CONFIG > /etc/skel/.config/autostart/firefox.desktop
[Desktop Entry]
Type=Application
Exec=/usr/bin/firefox
Hidden=false
NoDisplay=false
X-GNOME-Autostart-enabled=true
Name[en_US]=firefox
Name=firefox
Comment[en_US]=
Comment=
CONFIG
echo 'user_pref("browser.startup.homepage", "http://localhost:10000");' >> /etc/firefox/profile/prefs.js
# We have a utility to prompt the user for a new root password if it has
# not been set yet.
cp $SCRIPT_DIR/set-root-pass.pl /usr/local/bin/
cat <<-CONFIG > /etc/skel/.config/autostart/set-root-pass.desktop
[Desktop Entry]
Type=Application
Exec=/usr/local/bin/set-root-pass.pl
Hidden=false
NoDisplay=false
X-GNOME-Autostart-enabled=true
Name[en_US]=set-root-pass.pl
Name=set-root-pass.pl
Comment[en_US]=
Comment=
CONFIG
# Set up our uck environment for the OD-clients
# Grab the 11.10 iso from the net and use the uck tools to unpack it
echo "Copy the Ubuntu ISO into the chroot. ~/tmp/remaster-root/root/"
echo "Press enter when you are done."
read
#wget -O /root/ubuntu-11.10-desktop-i386.iso "http://us.releases.ubuntu.com/oneiric/ubuntu-11.10-desktop-i386.iso"
mkdir -p /usr/local/uck
uck-remaster-unpack-iso /root/ubuntu-11.10-desktop-i386.iso /usr/local/uck
uck-remaster-unpack-rootfs /usr/local/uck
rm -rf /root/ubuntu-11.10-desktop-i386.iso
#NOTE: we first install language pack, then remove others as installing language pack might pull packages
#which were not previously present
echo "Removing unnecessary language packages..."
REMOVED_PACKAGES=`dpkg-query --show | cut -f1 | grep -E '^(language-pack|language-support)' | grep -v -E "[-]($LANGPACKS_CONCATENATED)\>"`
remove_packages $REMOVED_PACKAGES || failure "Removing packages failed, error=$?"
fi
if [ "$RUN_MANUAL_CUSTOMIZATIONS" = "yes" ] ; then
while true ; do
CHOICE_PACKAGE_MANAGER="Run package manager"
CHOICE_CONSOLE="Run console application"
CHOICE_EXIT="Continue building"
CHOICE=`dialog_menu "Please choose customization action" "$CHOICE_PACKAGE_MANAGER" "$CHOICE_CONSOLE" "$CHOICE_EXIT"`
RESULT=$?
if [ $RESULT -ne 0 ] ; then
failure "Script cancelled by user"
fi
#workaround for KDE bug (https://bugs.kde.org/show_bug.cgi?id=139025)
CHOICE=`echo "$CHOICE" | grep -v -i kwrited | tail -n1`
echo "CHOICE='$CHOICE'"
if [ "$CHOICE" = "$CHOICE_EXIT" ] ; then
break
elif [ "$CHOICE" = "$CHOICE_PACKAGE_MANAGER" ] ; then
run_package_manager
elif [ "$CHOICE" = "$CHOICE_CONSOLE" ] ; then
run_console
fi
done
fi
apt-get -y autoremove
apt-get -y clean
echo "Done"
You can’t perform that action at this time.