##### Puppet Matlab #####

### Use Aptly this time because it is easier.

apt-get install aptly

# make key
gpg --gen-key
kind of key:    (4) RSA (sign only)
keysize:        4096
valid for:      0
Real name:      
passphrease:    

# list keys
root@mirror:~# gpg --list-keys

gpg --output ucdmath-pubkey.asc --armor --export  

# create repo
aptly repo create -distribution=ucdmath -component=main  ucdmath

# Make your deb package(s) from existing install.

# add packages
aptly repo add ucdmath debs
Loading packages...
[+] mathematica_amd64 added
[+] matlab_amd64 added

# publish repo
root@mirror:/var/www# aptly publish repo ucdmath

# install key server
apt-get install sks

# browse sks
http://mirror:11371/

# Send key to SKS server
root@mirror:/var/www/aptly/public# gpg --keyserver mirror.math.ucdavis.edu --send-keys 53077E873428A628B6E740EC41219196C4953C41


# Set up Apache (put symlink named ucdmath to aptly public dir)


# set up puppet apt module
puppet module install --ignore-dependencies puppetlabs-apt


# write manifest for matlab

# puppet matlab module by zj

class ucdmath_matlab::source {
  apt::source { 'ucdmath':
    location          => '[arch=amd64] http://mirror.math.ucdavis.edu/ucdmath',
    release           => 'ucdmath',
    repos             => 'main',
    key               => '53077E873428A628B6E740EC41219196C4953C41',
    key_server        => 'mirror.math.ucdavis.edu',
    include_src       => false
  }
}
class ucdmath_matlab::present {
  package {'matlab':
    ensure => present,
    require => Class["ucdmath_matlab::source"],
  }
}
class ucdmath_matlab::config {
  file { "/opt/pkg/mathworks/matlab-2011b/licenses/network.lic":
    owner => "root",
    group => "root",
    mode => 0644,
    source => "puppet://$puppetserver/modules/ucdmath_matlab/network.lic",
    require => Class["ucdmath_matlab::present"],
  }
  file { "/critical/icons/matlab.png":
    owner => "root",
    group => "root",
    mode => 0644,
    source => "puppet://$puppetserver/modules/ucdmath_matlab/critical/icons/matlab.png",
    require => Class["ucdmath_matlab::present"],
  }
  file { "/usr/share/applications/matlab.desktop":
    owner => "root",
    group => "root",
    mode => 0644,
    source => "puppet://$puppetserver/modules/ucdmath_matlab/usr/share/applications/matlab.desktop",
    require => Class["ucdmath_matlab::present"],
  }
  file { "/usr/local/bin/matlab":
    ensure => 'link',
    target => '/opt/pkg/mathworks/matlab-2011b/bin/matlab',
    require => Class["ucdmath_matlab::present"],
  }
  file { "/lib64/libc.so.6":
    ensure => 'link',
    target => '/lib/x86_64-linux-gnu/libc.so.6',
    require => Class["ucdmath_matlab::present"],
  }
}
class ucdmath_matlab::absent {
  package {'matlab':
    ensure => absent,
  }
}
class ucdmath_matlab {
  include ucdmath_matlab::source, ucdmath_matlab::present, ucdmath_matlab::config
}