parent
9a7465bfd5
commit
44bf0a5d6d
@ -1,4 +1,4 @@
|
||||
find_package( Qt5 COMPONENTS Core REQUIRED )
|
||||
find_package( Qt5 ${QT_VERSION} CONFIG REQUIRED Core DBus Network )
|
||||
find_package( Crypt REQUIRED )
|
||||
|
||||
# Add optional libraries here
|
||||
@ -36,6 +36,7 @@ calamares_add_plugin( users
|
||||
calamaresui
|
||||
${CRYPT_LIBRARIES}
|
||||
${USER_EXTRA_LIB}
|
||||
Qt5::DBus
|
||||
SHARED_LIB
|
||||
)
|
||||
|
||||
|
@ -27,6 +27,9 @@
|
||||
|
||||
#include <QDir>
|
||||
#include <QFile>
|
||||
#include <QtDBus/QDBusConnection>
|
||||
#include <QtDBus/QDBusInterface>
|
||||
#include <QtDBus/QDBusReply>
|
||||
|
||||
SetHostNameJob::SetHostNameJob( const QString& hostname )
|
||||
: Calamares::Job()
|
||||
@ -79,6 +82,32 @@ ff02::2 ip6-allrouters
|
||||
.failed() );
|
||||
}
|
||||
|
||||
static void
|
||||
setSystemdHostname( const QString& hostname )
|
||||
{
|
||||
QDBusInterface hostnamed( "org.freedesktop.hostname1",
|
||||
"/org/freedesktop/hostname1",
|
||||
"org.freedesktop.hostname1",
|
||||
QDBusConnection::systemBus() );
|
||||
|
||||
// Static, writes /etc/hostname
|
||||
{
|
||||
QDBusReply< uint > r = hostnamed.call( "SetStaticHostname", hostname, false );
|
||||
if ( !r.isValid() )
|
||||
{
|
||||
cWarning() << "Could not set hostname through org.freedesktop.hostname1.SetStaticHostname." << r.error();
|
||||
}
|
||||
}
|
||||
// Dynamic, updates kernel
|
||||
{
|
||||
QDBusReply< uint > r = hostnamed.call( "SetHostname", hostname, false );
|
||||
if ( !r.isValid() )
|
||||
{
|
||||
cWarning() << "Could not set hostname through org.freedesktop.hostname1.SetHostname." << r.error();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Calamares::JobResult
|
||||
SetHostNameJob::exec()
|
||||
|
Loading…
Reference in New Issue
Block a user