<div dir="ltr"><div><div>Hi Linuxcontainers.org, :)<br><br></div>this is my first post to this list and I just wanted to reply to a post<br><a href="https://lists.linuxcontainers.org/pipermail/lxc-users/2016-August/012083.html">https://lists.linuxcontainers.org/pipermail/lxc-users/2016-August/012083.html</a>. <br><br>Because I just subscribed to the list, I can not reply to that post, so here is a short script<br>I've been using and it seems to be working ok in LXC/LXD envs that I'm on.<br><br></div>---------------<br>#!/bin/bash<br>#####################################################################<br>## _Bash function to determine the 'host_role'<br># Check whether we are a LXC-container or not (i.e host)?<br># - = (no args)<br># - return (echo): 0 = not container/host, 1 = LXC-container<br>## Author: Jukka Aaltonen, Koha-Lappi -migration project<br>#####################################################################<br>function _host-role {<br>    rc=0<br>    host_role="Host/platform"<br><br>    ## Check whether we are a LXC-container<br>    sudo grep -qa "container=lxc" /proc/1/environ<br>    if [[ $? -eq 0 ]]; then<br>        host_role="LXC-container"; rc=1<br>    else<br>        host_role="Host/platform"; rc=0<br>    fi<br>    echo "Hostname (LXC-guest/host):$(hostname) ($host_role)"<br><br>    return $rc<br>}<br>---------------<br><div><br></div><div>HTH<br><br></div><div>-jukka<br></div></div>