diff options
Diffstat (limited to 'modules')
-rw-r--r-- | modules/buildsystem/manifests/init.pp | 37 | ||||
-rwxr-xr-x | modules/buildsystem/templates/upload-bin | 26 |
2 files changed, 63 insertions, 0 deletions
diff --git a/modules/buildsystem/manifests/init.pp b/modules/buildsystem/manifests/init.pp index 1d9db998..d517a664 100644 --- a/modules/buildsystem/manifests/init.pp +++ b/modules/buildsystem/manifests/init.pp @@ -209,6 +209,43 @@ class buildsystem { } } + + class binrepo { + $binrepo_login = "binrepo" + $binrepo_homedir = "/var/lib/$binrepo_login" + $binrepodir = "$binrepo_homedir/data" + $uploadinfosdir = "$binrepo_homedir/infos" + + user {"$binrepo_login": + ensure => present, + comment => "Binary files repository", + managehome => true, + shell => "/bin/bash", + home => "$binrepo_homedir", + } + + file { $binrepodir: + ensure => directory, + owner => $binrepo_login, + group => $binrepo_login, + mode => 755, + } + + file { $uploadinfosdir: + ensure => directory, + owner => $binrepo_login, + group => $binrepo_login, + mode => 755, + } + + file { '/usr/local/bin/upload-bin': + ensure => present, + owner => root, + group => root, + mode => 755, + content => template('buildsystem/upload-bin'), + } + } class mgarepo { package { 'mgarepo': diff --git a/modules/buildsystem/templates/upload-bin b/modules/buildsystem/templates/upload-bin new file mode 100755 index 00000000..30730874 --- /dev/null +++ b/modules/buildsystem/templates/upload-bin @@ -0,0 +1,26 @@ +#!/bin/sh +binrepodir=<%= binrepodir %> +uploadinfosdir=<%= uploadinfosdir %> +tmpfile=$(mktemp) +mail_from="root@mageia.org" +mail_dest="boklm@mars-attacks.org" + +username="$1" +comment="$2" + +/bin/cat > "$tmpfile" +sha1sum=$(/usr/bin/sha1sum "$tmpfile" | sed 's/ .*$//') +if [ -f "$binrepodir/$sha1sum" ] +then + echo "File $sha1sum already exists." >&2 + /bin/rm -f "$tmpfile" + exit 2 +fi +/bin/mv "$tmpfile" "$binrepodir/$sha1sum" +echo "$username:$comment" > "$uploadinfosdir/$sha1sum" +echo "User $username uploaded file $sha1sum: $comment" + +/usr/bin/mailx -s "New file uploaded: $sha1sum - $comment" -S "from=$username <$mail_from>" "$mail_dest" + +exit 0 + |