install.sh 6.97 KB
Newer Older
Mattia Rizzolo's avatar
Mattia Rizzolo committed
1 2 3 4 5 6 7 8
#!/bin/bash

dotfiles=(vimrc
          zshrc
          pbuilderrc
          quiltrc
          dput.cf
          conkyrc
9
          gitconfig
Mattia Rizzolo's avatar
Mattia Rizzolo committed
10
          pastebinit.xml
11
          xchat2/xchat.conf xchat2/servlist_.conf xchat2/notify.conf xchat2/chanserv-mod.py
12
          ssh/config
Mattia Rizzolo's avatar
Mattia Rizzolo committed
13 14 15 16 17 18 19 20 21 22 23
          mutt/muttrc mutt/mutt.sh mutt/signature mutt/colors mutt/gpg irssi/config
          )
files=(pbuilder/hooks
       pbuilder/scripts
       )
emptydotdirs=()
emptydirs=(pbuilder/result)
repos=(google-talkplugin.list)
reposdeb=()
packages=(geany
          google-talkplugin
24
          nautilus-dropbox
Mattia Rizzolo's avatar
Mattia Rizzolo committed
25
          filezilla
26
          conky
27
          skype
28 29
          ubuntu-restricted-exstras
          zram-config
Mattia Rizzolo's avatar
Mattia Rizzolo committed
30 31 32
          samba
          gimp
          inkscape
33 34 35 36 37 38
          clementine
          vlc
          calibre
          gdebi
          gparted
          playonlinux
39 40
          pass
          pastebinit
41
          virtualbox linux-headers-generic virtualbox-guest-addition-iso
42 43 44
          terminator
          unity-tweak-tool
          vim
45 46
          mutt
          irssi
47 48
          flashplugin-installer
          prelink preload
49
          steam
Mattia Rizzolo's avatar
Mattia Rizzolo committed
50 51 52
          cheese
          chromium-browser
          xchat
53
          zsync
Mattia Rizzolo's avatar
Mattia Rizzolo committed
54 55
          eatmydata #to use pbuilder quickly
          build-essential
56 57 58
          debhelper dh-make dh-systemd
          git git-buildpackage
          subversion
Mattia Rizzolo's avatar
Mattia Rizzolo committed
59 60 61
          ubuntu-dev-tools
          pbuilder
          lintian
62
          cdbs
Mattia Rizzolo's avatar
Mattia Rizzolo committed
63 64 65 66
          gnupg2 gnupg-agent
          )

personal () {
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
    sublime () {
        if ( ! dpkg -l sublime-text &> /dev/null ); then
        echo "Installing sublime-text..."
        sudo dpkg -i sublime-text*_`dpkg --print-architecture`.deb
        sudo apt-get -f install
        fi
    }
    prelink () {
        if ( dpkg -l prelink &> /dev/null );then
            NEW=false
            if [ -f /etc/default/prelink ] ; then
                if ( ! grep "PRELINKING=yes" /etc/default/prelink &> /dev/null ); then
                    TEMPFILE=`mktemp`
                    sed s/PRELINKING=unknown/PRELINKING=yes/g /etc/default/prelink > $TEMPFILE
                    sudo cp $TEMPFILE /etc/default/prelink
                    rm $TEMPFILE
                    NEW=true
                fi
            fi
            if [ -f /etc/prelink.conf ] ; then
                if ( ! grep "/usr/bin/skype" /etc/prelink.conf &> /dev/null ); then
                    sudo sh -c 'echo "-b /usr/bin/skype" >> /etc/prelink.conf'
                    NEW=true
                fi
            fi
            if $NEW ; then
                sudo prelink -a &
            fi
        fi
    }
97 98 99 100 101 102 103
    musiclink () {
        if [ -d $HOME/Music && -e /media/Dati/Music ] ; then
            echo "Creating $HOME/Music symlink"
            rmdir $HOME/Music
            ln -s /media/Dati/Music $HOME/Music
        fi
    }
104 105 106

    sublime
    prelink
107
    musiclink
Mattia Rizzolo's avatar
Mattia Rizzolo committed
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194
}

# This function create files, directories and symlinks, as needed
files () {
    echo "Creating empty dirs..."
    for dir in ${emptydotdirs[@]}; do
        if [ ! -a $HOME/.${dir} ] ; then
            mkdir -pv $HOME/.${dir}
        fi
    done
    for dir in ${emptydirs[@]}; do
        if [ ! -a $HOME/${dir} ] ; then
            mkdir -pv $HOME/${dir}
        fi
    done

    echo "Creating symlinks..."
    for file in ${dotfiles[@]}; do
        # for files
        if [ -f $HOME/settings/${file} ] ; then
            if [ -a $HOME/.${file} ] ; then
                rm $HOME/.${file}
            fi
            if (echo ${file} | grep -q '/' && [ ! -d $HOME/.$(echo ${file} | cut -f 1 -d '/') ]) ; then
                mkdir $HOME/.$(echo ${file} | cut -f 1 -d '/')
            fi
            ln -s $HOME/settings/${file} $HOME/.${file}
        fi
        # for directories
        if [ -d $HOME/settings/${file} ] ; then
            #file=$(echo $file | cut -f 1 -d '/')
            if [ -a $HOME/.${file} ] ; then
                rm -r $HOME/.{file}
            fi
            ln -s $HOME/settings/${file} $HOME/.${file}
        fi
    done
    for file in ${files[@]}; do
        #for files
        if [ -f $HOME/settings/${file} ] ; then
            if [ -a $HOME/${file} ] ; then
                rm $HOME/${file}
            fi
            ln -s $HOME/settings/${file} $HOME/${file}
        fi
        # for directories
        if [ -d $HOME/settings/${file} ] ; then
            if [ -a $HOME/${file} ] ; then
                rm -r $HOME/${file}
            fi
            ln -s $HOME/settings/${file} $HOME/${file}
        fi
    done
}

## add repositories, as needed
#add-repo () {
#    echo "alpha feature! not tested! it can kill you, your mother and your cat!"
#    echo "do you still want to run this script? [y/N]"
#    read reply
#    if [ ${reply} != 'y' !! ${reply} != 'Y' ]
#        then
#            echo "you made the better choice, brother!"
#            exit 2
#    echo "Adding required repositories..."
#    for repo in ${repos[@]}; do
#        tmp=`grep '^deb' ${repo}|tail -n 1|awk {'print $2'}`
#        echo repo: $tmp
#        dir="/etc/apt/sources.list.d/*"
#        if $( grep -v '${tmp}' ${dir} )
#            then
#                echo "Adding \"${repo}\" repository"
#                sudo cp ${repo} /etc/apt/sources.list.d/
#        fi
#    done
#    for repo in ${reposdeb[@]}; do
#        if [ ! $(grep -r ${repo} /etc/apt/sources.list*) ]
#            then
#                echo "Adding \"${repo}\" repository"
#                sudo add-apt-repository --yes ${repo}
#        fi
#    done
#}

## install the required packages, as needed
install () {
    echo "Updating repository information..."
195
    sudo apt-get -q update
Mattia Rizzolo's avatar
Mattia Rizzolo committed
196 197 198 199 200
    echo "Installing packages..."
    package=$(echo ${packages[@]} | tr '\n' ' ')
    sudo apt-get install -y ${package}
}

201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228
dropboxlinks () {
    echo "Creating link to Dropbox folder"
    DIRShome=(Documents Pictures Public Templates)
    DIRSrootdb=(Develop FCM)

    for dir in ${DIRShome[@]}; do
        if ( [ -d $HOME/${dir} ] || [ ! -e $HOME/${dir} ] ) && [ -d $HOME/Dropbox/home/${dir} ] ; then
            if [ -e $HOME/${dir} ] ; then rmdir $HOME/${dir} ; fi
            ln -s $HOME/Dropbox/home/${dir} $HOME/${dir}
        fi
    done
    for dir in ${DIRSrootdb[@]}; do
        if ( [ -d $HOME/${dir} ] || [ ! -e $HOME/${dir} ] ) && [ -d $HOME/Dropbox/${dir} ] ; then
            if [ -d $HOME/${dir} ] ; then rmdir $HOME/${dir} ; fi
            ln -s $HOME/Dropbox/${dir} $HOME/${dir}
        fi
    done
}

help () {
    cat << EOF
    Valid options are:
     -a                 Add repositories
     -i                 First-installation useful stuff (apt-get update/upgrade)
     -h                 Show this help
EOF
}

229
while getopts ":ai" opt; do
Mattia Rizzolo's avatar
Mattia Rizzolo committed
230 231 232 233 234
  case $opt in
    a)
      #ADDREPO=1
      echo "The add-repo function is broken. Going on..."
      ;;
235 236 237 238 239
    i)
      echo "Running first-installation stuff..."
      sudo apt-get update
      sudo apt-get dist-upgrade -y
      ;;
240 241 242
    h)
      help
      ;;
Mattia Rizzolo's avatar
Mattia Rizzolo committed
243 244
    *)
      echo "Unrecognised option: -$OPTARG."
245
      help
Mattia Rizzolo's avatar
Mattia Rizzolo committed
246 247 248 249 250 251 252 253 254 255 256
      exit 1
      ;;
  esac
done

files
#if (ADDREPO==1); then add-repo ; fi
install
personal

exit 0