aboutsummaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorNicolas Vigier <boklm@mageia.org>2011-08-16 22:38:24 +0000
committerNicolas Vigier <boklm@mageia.org>2011-08-16 22:38:24 +0000
commit2a97b90821f2ac84df158dbe5aab4be1410af034 (patch)
tree5ae0e0df0d6d103f3481b153149418fa41b6dace /modules
parent57bd006438f36891b7d7864c423c43a34498789d (diff)
downloadpuppet-2a97b90821f2ac84df158dbe5aab4be1410af034.tar
puppet-2a97b90821f2ac84df158dbe5aab4be1410af034.tar.gz
puppet-2a97b90821f2ac84df158dbe5aab4be1410af034.tar.bz2
puppet-2a97b90821f2ac84df158dbe5aab4be1410af034.tar.xz
puppet-2a97b90821f2ac84df158dbe5aab4be1410af034.zip
add script to upload binrepo files
Diffstat (limited to 'modules')
-rw-r--r--modules/buildsystem/manifests/init.pp37
-rwxr-xr-xmodules/buildsystem/templates/upload-bin26
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
+