# Post installation script

# Dynamically populated directories that we expect to exist but do
# not want to remove when removing the RPM. Ideally, we would do this
# via the RPM building plugin, but adding empty directories is not
# supported.
install --directory --mode=755 /var/lib/presto
install --directory --mode=755 /var/log/presto

# Populate node.id from uuidgen by replacing template with the node uuid
sed -i "s/\$(uuid-generated-nodeid)/$(uuidgen)/g" /etc/presto/node.properties

# move the presto_env.sh created during pre-install to presto config location
if [ -e /tmp/presto_env.sh ]
then
    mv /tmp/presto_env.sh /etc/presto/env.sh
else
    echo "#JAVA_HOME=" > /etc/presto/env.sh
fi

chown -R presto:presto /var/lib/presto
chown -R presto:presto /var/log/presto
chown -R presto:presto /etc/presto
