#!/bin/sh -e

node=$1
if [ -z "$node" ]; then
    echo "node name is mandatory argument."
    exit 1;
fi
autorepo-altnode-admin-create-node $node
mkdir -p /var/ftp/pub/ALTLinux
chmod 775 /var/ftp/pub/ALTLinux
chgrp robots /var/ftp/pub/ALTLinux
mkdir -p /var/ftp/pub/ALTLinux/$node
chown -R $node /var/ftp/pub/ALTLinux/$node

autorepo_altnode_builder=`rpmquery -a --qf '%{NAME}\n' | grep '^autorepo-altnode-builder$'`
if [ -z "$autorepo_altnode_builder" ]; then
    apt-get update
    apt-get install autorepo-altnode-builder
fi

#[ -x setup_build_node.sh ] && su - $node < setup_build_node.sh
