From 335026af09fd4bd5661a08546649e8567046ee13 Mon Sep 17 00:00:00 2001
From: Jan-Philipp Litza <janphilipp@litza.de>
Date: Sat, 21 Mar 2015 13:21:49 +0100
Subject: [PATCH] Allow empty hostname prefix

In Bremen it has been noted that a prefix may lead people to believe it
has to stay there and thus naming their nodes "ffhb-*", which is not
what the community wants (see FreifunkBremen/gluon-site-ffhb#1).

However, an empty prefix lead to the connecting hyphen still being
inserted. This commit thus makes the hyphen part of the configured
prefix and allows the prefix to be missing from the `site.conf`.
---
 package/gluon-core/check_site.lua                     | 2 +-
 package/gluon-core/files/lib/gluon/upgrade/030-system | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/package/gluon-core/check_site.lua b/package/gluon-core/check_site.lua
index 67035c0e9..1a6987a00 100644
--- a/package/gluon-core/check_site.lua
+++ b/package/gluon-core/check_site.lua
@@ -1,7 +1,7 @@
 need_string 'site_code'
 need_string 'site_name'
 
-need_string 'hostname_prefix'
+need_string('hostname_prefix', false)
 need_string 'timezone'
 
 need_string_array('ntp_servers', false)
diff --git a/package/gluon-core/files/lib/gluon/upgrade/030-system b/package/gluon-core/files/lib/gluon/upgrade/030-system
index b31ba42e7..d7a666050 100755
--- a/package/gluon-core/files/lib/gluon/upgrade/030-system
+++ b/package/gluon-core/files/lib/gluon/upgrade/030-system
@@ -10,7 +10,7 @@ if not sysconfig.gluon_version then
 
   local system = uci:get_first('system', 'system')
 
-  uci:set('system', system, 'hostname', site.hostname_prefix .. '-' .. util.node_id())
+  uci:set('system', system, 'hostname', (site.hostname_prefix or '') .. util.node_id())
   uci:set('system', system, 'timezone', site.timezone)
 
   uci:save('system')
-- 
GitLab