preinstall.sh 2.09 KB
Newer Older
David Beniamine's avatar
David Beniamine committed
1
#!/bin/bash
David Beniamine's avatar
David Beniamine committed
2 3 4
logfile="/var/log/`basename $0`_`date +%Y%m%d-%H%M`"
exec &> >(tee -a "$logfile")

5 6 7 8 9 10 11 12 13 14 15 16
# Usage test_and_fail $? "message"
# If the return code is not 0, fails displaying the message
function test_and_fail(){
    code=$1
    shift
    if [ $code -ne 0 ]
    then
        echo $@
        exit $code
    fi
}

David Beniamine's avatar
David Beniamine committed
17 18 19 20 21 22
if [ `whoami` != "root" ]
then
    echo "This script should be run as root"
    exit 1
fi
DIR=`dirname $0`
23

David Beniamine's avatar
David Beniamine committed
24

David Beniamine's avatar
David Beniamine committed
25 26
#echo "Fixing network issues"
#$DIR/fix_network.sh
David Beniamine's avatar
David Beniamine committed
27

28

David Beniamine's avatar
David Beniamine committed
29 30 31 32
PROXY_URL="http://dnsproxy:3128"

echo "Installating packages"
apt-get update
33
test_and_fail $? "Cannot update apt cache"
David Beniamine's avatar
David Beniamine committed
34
DEBIAN_FRONTEND='noninteractive' apt-get -o Dpkg::Options::="--force-confold" -y upgrade
35
test_and_fail $? "Cannot run upgrade"
David Beniamine's avatar
David Beniamine committed
36
DEBIAN_FRONTEND='noninteractive' apt-get -o Dpkg::Options::="--force-confold" -y dist-upgrade
37
test_and_fail $? "Cannot run dist upgrade"
David Beniamine's avatar
David Beniamine committed
38

David Beniamine's avatar
David Beniamine committed
39
DEBIAN_FRONTEND='noninteractive' apt-get -o Dpkg::Options::="--force-confold" -y install \
David Beniamine's avatar
David Beniamine committed
40
    cifs-utils \
41
    conky \
David Beniamine's avatar
David Beniamine committed
42 43
    cups-browsed \
    libdvdcss2 \
44
    language-selector-common \
David Beniamine's avatar
David Beniamine committed
45
    netcat \
David Beniamine's avatar
David Beniamine committed
46
    numlockx \
David Beniamine's avatar
David Beniamine committed
47
    tftp \
David Beniamine's avatar
David Beniamine committed
48
    ttf-mscorefonts-installer \
49
    vlc \
David Beniamine's avatar
David Beniamine committed
50
    vlc-plugin-fluidsynth \
51
    x11vnc
52
test_and_fail $? "Cannot install required packages"
53

54 55 56
echo "Adding x11vnc"
cp $DIR/x11vnc.desktop /usr/share/applications/

David Beniamine's avatar
David Beniamine committed
57 58 59 60 61 62 63
u="direction"
echo "Creating users $u"
groupadd direction
useradd $u  --create-home \
    --groups $u,cdrom,dip,plugdev,lpadmin,sambashare \
    --gid $u \
    --shell /bin/bash
David Beniamine's avatar
David Beniamine committed
64

65
echo "Configuring user session"
66
cp $DIR/session.sh /usr/local/bin/
David Beniamine's avatar
David Beniamine committed
67 68
for u in $USERS
do
David Beniamine's avatar
David Beniamine committed
69
    profile=`awk -F = '/^Path/{print $2}' /home/$u/.mozilla/firefox/profiles.ini`
David Beniamine's avatar
David Beniamine committed
70
    echo "$u uses profile $profile"
David Beniamine's avatar
David Beniamine committed
71
    preffile="/home/$u/.mozilla/firefox/$profile/prefs.js"
David Beniamine's avatar
David Beniamine committed
72
    echo $preffile
David Beniamine's avatar
David Beniamine committed
73
    sed -i.bak -e '/user_pref("network.proxy.type")/d' $preffile
David Beniamine's avatar
David Beniamine committed
74 75 76 77 78
    echo 'user_pref("network.proxy.type", 4);' >> $preffile
done

echo "Adding apt proxy"
debfile="/etc/apt/apt.conf.d/70debconf"
David Beniamine's avatar
David Beniamine committed
79
sed -i.bak -e '/Acquire::http::Proxy/d' $debfile
David Beniamine's avatar
David Beniamine committed
80
echo "Acquire::http::Proxy \"$PROXY_URL\";" >> $debfile
David Beniamine's avatar
David Beniamine committed
81
echo "Acquire::https::Proxy \"$PROXY_URL\";" >> $debfile
David Beniamine's avatar
David Beniamine committed
82

83
$DIR/update_configurations.sh