]> git.donarmstrong.com Git - neurodebian.git/blob - tools/nd-vmsetupwizard
Simplify logfile parser to spit out JSON
[neurodebian.git] / tools / nd-vmsetupwizard
1 #!/bin/bash
2 #emacs: -*- mode: shell-script; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: nil -*-
3 #ex: set sts=4 ts=4 sw=4 et:
4
5 # play save
6 set -e
7 set -u
8
9 cfg_dir=/etc/neurodebian/guest/setupwizard_done
10 success_flag=$cfg_dir/setupwizard_done
11 nd_icon=/usr/share/pixmaps/neurodebian.svg
12 icon_opt="--window-icon=$nd_icon"
13
14 first_run=0
15 if [ ! -e $success_flag ]; then
16         first_run=1
17 fi
18
19 if [ $first_run -eq 1 ]; then
20 zenity --info $icon_opt --title="NeuroDebian Setup Wizard" \
21        --text="Welcome to the NeuroDebian virtual machine!
22
23 This is the first time you have started this virtual machine. We will now perform a few simple steps to finalize its configuration. This includes upgrading the system to the latest available versions and installing additional software packages upon your request."
24 fi
25
26 if ! zenity --question $icon_opt --title="NeuroDebian Setup Wizard" \
27 --text="The setup procedure requires network access to download packages from the Debian archive. If you do not have network access right now, you can re-start this wizard at any time from the NeuroDebian menu. If you proceed you may have to enter the superuser password with is by default 'neurodebian'.
28
29 Do you want to proceed with updating the system?
30 "; then
31         exit 0
32 fi
33
34 # initialize apt
35 update-manager -c
36
37 sudo update-software-center --debug 2>&1 | \
38         zenity $icon_opt --title="Updating Software Center Repository"  \
39                 --progress  --pulsate --auto-close --auto-kill 
40
41 popconf=/etc/popularity-contest.conf
42 if [ ! -e "$popconf" ] || grep -q -e '^PARTICIPATE.*no' "$popconf" ;
43 then
44         zenity --info $icon_opt --title="NeuroDebian Setup Wizard" \
45                 --text="You will now be given the choice to participate in the package survey. If enabled, a list of installed packages will be anonymously sent to Debian (http://popcon.debian.org). Your participation is important for two reasons:
46
47 1) Popular packages receive more attention from developers, bugs are fixed faster and updates are provided quicker.
48 2) User statistics can help research software developers to acquire funding for continued development."
49
50         if [ -e "$popconf" ] ; then
51         # just reconfigure so user could get a chance to participate
52                 sudo DEBIAN_FRONTEND=gnome dpkg-reconfigure popularity-contest
53         else
54         # install, but do not fail if something goes wrong
55                 nd-autoinstall popularity-contest /etc/popularity-contest.conf || true
56         fi
57 fi
58
59 # install custom filter for synaptics
60 if [ $first_run -eq 1 ]; then
61         sudo mkdir -p /root/.synaptic
62         sudo bash -c 'cat << EOT >> /root/.synaptic/filters
63 filter "NeuroDebian" {
64   section {
65     inclusive false;
66     sections {
67     };
68   };
69   status {
70     flags 0x1ffff;
71   };
72   pattern {
73     andMode 0;
74     patterns {
75       Origin; "neuro.debian.net"; false;
76       Maintainer; "team@neuro.debian.net"; false;
77     };
78   };
79   priority {
80   };
81   reducedview {
82     enabled false;
83   };
84 };
85 EOT
86 '
87         # essential things are done -- let's mark sucess
88         sudo bash -c "mkdir -p $cfg_dir && touch $success_flag"
89 fi
90
91 if ! grep -q '/etc/fsl/fsl.sh' $HOME/.profile && \
92    zenity --question $icon_opt --title="FSL/AFNI Environments" \
93 --text="Packages, such as AFNI and FSL, provide large collections of command line tools which are available from their private directories, and require custom environment variables to be set for proper functioning.  Usually you need to source /etc/fsl/fsl.sh or /etc/afni/afni.sh in your environments.
94
95 Do you want to get those files, if available, sourced automatically for your environment?
96 "; then
97    for t in fsl afni cmtk freesurfer; do
98         cf="/etc/$t/$t.sh"
99         grep -q -e "$cf" $HOME/.profile || \
100                 echo "[ -e \"$cf\" ] && . $cf" >> $HOME/.profile
101    done
102 fi
103
104 # create symlink to shared folder into homedir
105 # note: -e check would exit 1 if link is broken
106 #       ln -f is used for further robustness
107 [ ! -L $HOME/host ] && ln -sf /media/sf_host $HOME/host
108
109 # Figure out which version of IPython is available
110 ipython_version=$(apt-cache policy ipython 2>/dev/null | sed -ne '/Version table:/ { n;s,^[ \*]*\(.*\) .*,\1,gp}')
111 dpkg --compare-versions $ipython_version lt 0.13.1 && ipython=ipython01x || ipython=ipython
112
113 # TODO: add PyMVPA:
114 #   FALSE "PyMVPA" "python-mvpa2,python-mvpa2-doc,python-mvpa2-tutorial-data" \
115 # needs -doc and -tutorial-data package
116 packages=$(zenity --height 450 --list $icon_opt --checklist --column="Install" --column="Description" \
117            --column="Package Name" --print-column=3 --hide-column=3 --hide-header \
118            --separator=' ' --text="Please select any additional component that shall be installed.
119
120 Please note that this selection will not affect packages already installed
121 on the system. No installed packages will be reinstalled or removed, only
122 additional components will be installed." \
123 FALSE "Emacs" "emacs" \
124 FALSE "Graphics (e.g. GIMP, Inscape)" "gimp,inkscape,svgtune,xzgv,vym" \
125 FALSE "Octave" "qtoctave" \
126 FALSE "OpenOffice.org" "openoffice.org" \
127 FALSE "PyMVPA Tutorial" "$ipython,python-mvpa2,python-mvpa2-doc,python-mvpa2-tutorialdata,spyder" \
128 FALSE "Python: Electrophysiology & Modeling" "python-brian,python-pynn,python-pyentropy,stimfit" \
129 FALSE "Python: Neuroimaging" "$ipython,spyder,nipy-suite,python-mvpa2" \
130 FALSE "Python: Scientific stack" "$ipython,spyder,python-matplotlib,python-pandas,python-sympy" \
131 FALSE "R" "r-recommended" \
132 FALSE "TeX Live" "texlive" \
133 FALSE "Adobe Flash browser plugin" "flashplugin-nonfree" \
134 || true)
135
136 if [ -n "$packages" ]; then
137         for pkgs in $packages; do
138                 nd-autoinstall -f -p "${pkgs//,/ }" true
139         done
140 fi
141
142 # some sane ending
143 zenity --info $icon_opt --text="Wizard has finished."
144
145 # and start greeter
146 x-www-browser http://neuro.debian.net/vm_welcome.html &