preinstall.sh 2.49 KB
Newer Older
David Beniamine's avatar
David Beniamine committed
1 2 3 4 5 6 7
#!/bin/bash
if [ `whoami` != "root" ]
then
    echo "This script should be run as root"
    exit 1
fi
DIR=`dirname $0`
8 9 10 11 12

NEW_USERS="prof direction"
USERS="01-mini 02-super 03-maxi administrateur $NEW_USERS"
declare -A USER_COMMENTS
USER_COMMENTS=( \
David Beniamine's avatar
David Beniamine committed
13
    [01-mini]="01-CP"\
14 15
    [02-super]="02-CE1-CE2"\
    [03-maxi]="03-CM1-CM2"\
David Beniamine's avatar
David Beniamine committed
16 17 18
    [prof]="04-prof"\
    [direction]="05-direction"\
    [administrateur]="administrateur"\
19 20
    )

David Beniamine's avatar
David Beniamine committed
21
MANUAL_APP_TO_REMOVE="seamonkey dillo"
22

David Beniamine's avatar
David Beniamine committed
23 24 25 26
PROXY_URL="http://dnsproxy:3128"

echo "Installating packages"
apt-get update
27 28 29
apt-get -y install \
    appliplanet-primtux \
    ardora-primtux \
30
    conky \
31 32 33 34
    cups-browsed \
    evince \
    flash-primtux \
    libdvdcss2 \
David Beniamine's avatar
David Beniamine committed
35
    libreoffice-gtk \
36 37 38 39 40 41 42 43 44 45 46 47
    logiciels-primtux-maxi \
    logiciels-primtux-mini \
    logiciels-primtux-super \
    netcat \
    oracle-java8-installer \
    photofiltre-primtux \
    polices-ecole-primtux \
    thunderbird \
    thunderbird-l10n-fr \
    webstrict-primtux \
    x11vnc \
    xnview
David Beniamine's avatar
David Beniamine committed
48 49 50 51 52 53 54 55
apt-get -y remove --purge \
    dansguardian \
    dillo \
    proxy-protect-firefox-esr \
    tinyproxy \
    xournal \
    xpdf
apt-get -y autoremove --purge
David Beniamine's avatar
David Beniamine committed
56

57 58 59 60 61 62 63
echo "Adding x11vnc"
cp $DIR/x11vnc.desktop /usr/share/applications/

echo "Creating users $NEW_USERS"
for u in $NEW_USERS
do
    groupadd $u
64 65 66 67
    useradd $u --create-home \
        --groups $u,lp,users,cdrom,audio,video,plugdev,netdev,lpadmin,scanner,sambashare \
        --gid $u \
        --shell /bin/bash
68 69 70
done

echo "Renaming users"
David Beniamine's avatar
David Beniamine committed
71
for u in "${!USER_COMMENTS[@]}"
72
do
David Beniamine's avatar
David Beniamine committed
73
  usermod -c ${USER_COMMENTS[$u]} $u
74
done
David Beniamine's avatar
David Beniamine committed
75

76
echo "Configuring user session"
77
cp $DIR/session.sh /usr/local/bin/
David Beniamine's avatar
David Beniamine committed
78 79
for u in $USERS
do
David Beniamine's avatar
David Beniamine committed
80
    profile=`awk -F = '/^Path/{print $2}' /home/$u/.mozilla/firefox/profiles.ini`
David Beniamine's avatar
David Beniamine committed
81
    echo "$u uses profile $profile"
David Beniamine's avatar
David Beniamine committed
82
    preffile="/home/$u/.mozilla/firefox/$profile/prefs.js"
David Beniamine's avatar
David Beniamine committed
83
    echo $preffile
David Beniamine's avatar
David Beniamine committed
84
    sed -i.bak -e '/user_pref("network.proxy.type")/d' $preffile
David Beniamine's avatar
David Beniamine committed
85
    echo 'user_pref("network.proxy.type", 4);' >> $preffile
86
    # Script session de Eric
87
    sudo -u $u /usr/local/bin/session.sh
David Beniamine's avatar
David Beniamine committed
88 89 90 91
done

echo "Adding apt proxy"
debfile="/etc/apt/apt.conf.d/70debconf"
David Beniamine's avatar
David Beniamine committed
92
sed -i.bak -e '/Acquire::http::Proxy/d' $debfile
David Beniamine's avatar
David Beniamine committed
93
echo "Acquire::http::Proxy \"$PROXY_URL\";" >> $debfile
David Beniamine's avatar
David Beniamine committed
94
echo "Acquire::https::Proxy \"$PROXY_URL\";" >> $debfile
David Beniamine's avatar
David Beniamine committed
95 96 97 98 99 100 101 102 103 104 105 106

echo "Removing seamonkey and dillo"
for u in $USERS
do
    for prog in $MANUAL_APP_TO_REMOVE
    do
        find ~$u -name "seamonkey*" -exec rm -rf {} \;
    done
done

echo "Fixing network issues"
$DIR/fix_network.sh
107

108
echo "Update session"
109
$DIR/upgrade-session.sh