aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile1
-rw-r--r--initscripts.spec1
-rw-r--r--src/Makefile10
-rw-r--r--src/brandbot.c36
-rw-r--r--systemd/system/brandbot.path9
-rw-r--r--systemd/system/brandbot.service6
6 files changed, 62 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index 0a8d75b1..6b0ed084 100644
--- a/Makefile
+++ b/Makefile
@@ -98,6 +98,7 @@ install:
ln -s ../rhel-dmesg.service $(ROOT)/usr/lib/systemd/system/basic.target.wants
ln -s ../rhel-readonly.service $(ROOT)/usr/lib/systemd/system/local-fs.target.wants
ln -s ../rhel-import-state.service $(ROOT)/usr/lib/systemd/system/local-fs.target.wants
+ ln -s ../brandbot.path $(ROOT)/usr/lib/systemd/system/multi-user.target.wants
mkdir -p $(ROOT)/usr/lib/tmpfiles.d
install -m 644 initscripts.tmpfiles.d $(ROOT)/usr/lib/tmpfiles.d/initscripts.conf
diff --git a/initscripts.spec b/initscripts.spec
index 115aa2da..68805f2e 100644
--- a/initscripts.spec
+++ b/initscripts.spec
@@ -125,6 +125,7 @@ rm -rf $RPM_BUILD_ROOT
/etc/sysconfig/network-scripts/ifdown-post
/etc/sysconfig/network-scripts/ifup
/usr/sbin/ifup
+/usr/sbin/brandbot
%dir /etc/sysconfig/console
%dir /etc/sysconfig/modules
/etc/sysconfig/network-scripts/network-functions
diff --git a/src/Makefile b/src/Makefile
index dc4bf593..07d1f1f9 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -1,9 +1,10 @@
CFLAGS+=$(RPM_OPT_FLAGS) -Wall -D_GNU_SOURCE
LDFLAGS+=$(RPM_LD_FLAGS)
-PROGS=usernetctl netreport usleep ipcalc \
+PROGS=usernetctl netreport usleep ipcalc brandbot \
ppp-watch consoletype genhostid rename_device
PPPWATCH_OBJS=ppp-watch.o shvar.o
+BRANDBOT_OBJS=brandbot.o shvar.o
CONSOLE_INIT_OBJS=console_init.o shvar.o
USLEEP_OBJS=usleep.o
@@ -27,6 +28,7 @@ install:
install -m 755 ppp-watch $(ROOT)/usr/sbin/ppp-watch
install -m 755 consoletype $(ROOT)/usr/sbin/consoletype
install -m 755 sushell $(ROOT)/usr/sbin/sushell
+ install -m 755 brandbot $(ROOT)/usr/sbin/brandbot
install -m 755 rename_device $(ROOT)/usr/lib/udev/rename_device
install -m 644 genhostid.1 $(ROOT)$(mandir)/man1
install -m 644 netreport.1 $(ROOT)$(mandir)/man1
@@ -48,6 +50,9 @@ usleep: $(USLEEP_OBJS)
ppp-watch: $(PPPWATCH_OBJS)
$(CC) $(LDFLAGS) -o $@ $(PPPWATCH_OBJS) `pkg-config glib-2.0 --libs`
+brandbot: $(BRANDBOT_OBJS)
+ $(CC) $(LDFLAGS) -o $@ $(BRANDBOT_OBJS) `pkg-config glib-2.0 --libs`
+
usernetctl.o: usernetctl.c
$(CC) $(CFLAGS) -fPIE -c usernetctl.c -o usernetctl.o
@@ -63,6 +68,9 @@ netreport: netreport.o
shvar.o: shvar.c
$(CC) $(CFLAGS) `pkg-config glib-2.0 --cflags` -c shvar.c -o shvar.o
+brandbot.o: brandbot.c
+ $(CC) $(CFLAGS) `pkg-config glib-2.0 --cflags` -c brandbot.c -o brandbot.o
+
ppp-watch.o: ppp-watch.c
$(CC) $(CFLAGS) `pkg-config glib-2.0 --cflags` -c ppp-watch.c -o ppp-watch.o
diff --git a/src/brandbot.c b/src/brandbot.c
new file mode 100644
index 00000000..c9b21ecd
--- /dev/null
+++ b/src/brandbot.c
@@ -0,0 +1,36 @@
+
+#include <stdio.h>
+#include <string.h>
+
+#include <glib.h>
+
+#include "shvar.h"
+
+char *read_name() {
+ gchar *name = NULL;
+
+ g_file_get_contents("/var/lib/rhsm/branded_name", &name, NULL, NULL);
+ if (name)
+ name = g_strstrip(name);
+ return name;
+}
+
+int main(int argc, char **argv) {
+ shvarFile *osrelease;
+ char *newname, *oldname;
+ int rc = 0;
+
+ newname = read_name();
+ if (!newname)
+ return 0;
+ osrelease = svNewFile("/etc/os-release");
+ if (!osrelease)
+ return 0;
+ oldname = svGetValue(osrelease, "PRETTY_NAME");
+ if (!strcmp(oldname, newname))
+ return 0;
+ svSetValue(osrelease, "PRETTY_NAME", newname);
+ rc += svWriteFile(osrelease, 0644);
+ svCloseFile(osrelease);
+ return rc;
+}
diff --git a/systemd/system/brandbot.path b/systemd/system/brandbot.path
new file mode 100644
index 00000000..b3d5fca5
--- /dev/null
+++ b/systemd/system/brandbot.path
@@ -0,0 +1,9 @@
+[Unit]
+Description=Flexible branding
+
+[Path]
+PathExists=/var/lib/rhsm/branded_name
+PathChanged=/var/lib/rhsm/branded_name
+
+[Install]
+WantedBy=multi-user.target
diff --git a/systemd/system/brandbot.service b/systemd/system/brandbot.service
new file mode 100644
index 00000000..9b421b69
--- /dev/null
+++ b/systemd/system/brandbot.service
@@ -0,0 +1,6 @@
+[Unit]
+Description=Flexible Branding Service
+
+[Service]
+ExecStart=/usr/sbin/brandbot
+PrivateTmp=true