mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-27 07:23:09 +02:00
Hostname, #271. rcS needs hostname -F /etc/hostname before ifup
git-svn-id: file:///home/bas/coolstream_public_svn/THIRDPARTY/applications/neutrino-experimental@487 e54a6e83-5905-42d5-8d5c-058d10e6a962
This commit is contained in:
@@ -569,6 +569,7 @@ networkmenu.broadcast Broadcast
|
|||||||
networkmenu.dhcp DHCP
|
networkmenu.dhcp DHCP
|
||||||
networkmenu.gateway default gateway
|
networkmenu.gateway default gateway
|
||||||
networkmenu.head Network Settings
|
networkmenu.head Network Settings
|
||||||
|
networkmenu.hostname Hostname
|
||||||
networkmenu.ipaddress IP address
|
networkmenu.ipaddress IP address
|
||||||
networkmenu.mount NFS/CIFS/FTPFS
|
networkmenu.mount NFS/CIFS/FTPFS
|
||||||
networkmenu.nameserver name server
|
networkmenu.nameserver name server
|
||||||
|
@@ -205,9 +205,16 @@ char *netGetHostname( void )
|
|||||||
|
|
||||||
void netSetHostname( char *host )
|
void netSetHostname( char *host )
|
||||||
{
|
{
|
||||||
|
FILE * fp;
|
||||||
|
|
||||||
strcpy(hostbuf,host);
|
strcpy(hostbuf,host);
|
||||||
hostis=1;
|
hostis=1;
|
||||||
sethostname(hostbuf,strlen(hostbuf)+1);
|
sethostname(hostbuf,strlen(hostbuf)+1);
|
||||||
|
fp = fopen("/etc/hostname", "w");
|
||||||
|
if(fp != NULL) {
|
||||||
|
fprintf(fp, "%s\n", hostbuf);
|
||||||
|
fclose(fp);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void netSetNameserver(const char * const ip)
|
void netSetNameserver(const char * const ip)
|
||||||
|
@@ -368,6 +368,9 @@ bool setStaticAttributes(const std::string name, const bool automatic_start, con
|
|||||||
bool setDhcpAttributes(const std::string name, const bool automatic_start)
|
bool setDhcpAttributes(const std::string name, const bool automatic_start)
|
||||||
{
|
{
|
||||||
std::map<std::string, std::string> attribute;
|
std::map<std::string, std::string> attribute;
|
||||||
|
char hostname[100];
|
||||||
|
if(gethostname(hostname, sizeof(hostname)) == 0)
|
||||||
|
attribute["hostname"] = hostname;
|
||||||
|
|
||||||
return write_interface("/etc/network/interfaces", name, automatic_start, "inet", "dhcp", attribute);
|
return write_interface("/etc/network/interfaces", name, automatic_start, "inet", "dhcp", attribute);
|
||||||
}
|
}
|
||||||
|
@@ -1874,18 +1874,23 @@ void CNeutrinoApp::InitNetworkSettings(CMenuWidget &networkSettings)
|
|||||||
|
|
||||||
CSectionsdConfigNotifier* sectionsdConfigNotifier = new CSectionsdConfigNotifier;
|
CSectionsdConfigNotifier* sectionsdConfigNotifier = new CSectionsdConfigNotifier;
|
||||||
CStringInputSMS * networkSettings_NtpServer = new CStringInputSMS(LOCALE_NETWORKMENU_NTPSERVER, &g_settings.network_ntpserver, 30, LOCALE_NETWORKMENU_NTPSERVER_HINT1, LOCALE_NETWORKMENU_NTPSERVER_HINT2, "abcdefghijklmnopqrstuvwxyz0123456789-. ", sectionsdConfigNotifier);
|
CStringInputSMS * networkSettings_NtpServer = new CStringInputSMS(LOCALE_NETWORKMENU_NTPSERVER, &g_settings.network_ntpserver, 30, LOCALE_NETWORKMENU_NTPSERVER_HINT1, LOCALE_NETWORKMENU_NTPSERVER_HINT2, "abcdefghijklmnopqrstuvwxyz0123456789-. ", sectionsdConfigNotifier);
|
||||||
|
|
||||||
CStringInput * networkSettings_NtpRefresh = new CStringInput(LOCALE_NETWORKMENU_NTPREFRESH, &g_settings.network_ntprefresh, 3,LOCALE_NETWORKMENU_NTPREFRESH_HINT1, LOCALE_NETWORKMENU_NTPREFRESH_HINT2 , "0123456789 ", sectionsdConfigNotifier);
|
CStringInput * networkSettings_NtpRefresh = new CStringInput(LOCALE_NETWORKMENU_NTPREFRESH, &g_settings.network_ntprefresh, 3,LOCALE_NETWORKMENU_NTPREFRESH_HINT1, LOCALE_NETWORKMENU_NTPREFRESH_HINT2 , "0123456789 ", sectionsdConfigNotifier);
|
||||||
|
|
||||||
|
CStringInputSMS * networkSettings_Hostname = new CStringInputSMS(LOCALE_NETWORKMENU_HOSTNAME, &networkConfig.hostname, 30, LOCALE_NETWORKMENU_NTPSERVER_HINT1, LOCALE_NETWORKMENU_NTPSERVER_HINT2, "abcdefghijklmnopqrstuvwxyz0123456789-. ");
|
||||||
|
|
||||||
CMenuForwarder *m0 = new CMenuForwarder(LOCALE_NETWORKMENU_SETUPNOW, true, NULL, this, "network", CRCInput::RC_red, NEUTRINO_ICON_BUTTON_RED);
|
CMenuForwarder *m0 = new CMenuForwarder(LOCALE_NETWORKMENU_SETUPNOW, true, NULL, this, "network", CRCInput::RC_red, NEUTRINO_ICON_BUTTON_RED);
|
||||||
CMenuForwarder *m1 = new CMenuForwarder(LOCALE_NETWORKMENU_IPADDRESS , networkConfig.inet_static, networkConfig.address , networkSettings_NetworkIP );
|
CMenuForwarder *m1 = new CMenuForwarder(LOCALE_NETWORKMENU_IPADDRESS , networkConfig.inet_static, networkConfig.address , networkSettings_NetworkIP );
|
||||||
CMenuForwarder *m2 = new CMenuForwarder(LOCALE_NETWORKMENU_NETMASK , networkConfig.inet_static, networkConfig.netmask , networkSettings_NetMask );
|
CMenuForwarder *m2 = new CMenuForwarder(LOCALE_NETWORKMENU_NETMASK , networkConfig.inet_static, networkConfig.netmask , networkSettings_NetMask );
|
||||||
CMenuForwarder *m3 = new CMenuForwarder(LOCALE_NETWORKMENU_BROADCAST , networkConfig.inet_static, networkConfig.broadcast , networkSettings_Broadcast );
|
CMenuForwarder *m3 = new CMenuForwarder(LOCALE_NETWORKMENU_BROADCAST , networkConfig.inet_static, networkConfig.broadcast , networkSettings_Broadcast );
|
||||||
CMenuForwarder *m4 = new CMenuForwarder(LOCALE_NETWORKMENU_GATEWAY , networkConfig.inet_static, networkConfig.gateway , networkSettings_Gateway );
|
CMenuForwarder *m4 = new CMenuForwarder(LOCALE_NETWORKMENU_GATEWAY , networkConfig.inet_static, networkConfig.gateway , networkSettings_Gateway );
|
||||||
CMenuForwarder *m5 = new CMenuForwarder(LOCALE_NETWORKMENU_NAMESERVER, networkConfig.inet_static, networkConfig.nameserver, networkSettings_NameServer);
|
CMenuForwarder *m5 = new CMenuForwarder(LOCALE_NETWORKMENU_NAMESERVER, networkConfig.inet_static, networkConfig.nameserver, networkSettings_NameServer);
|
||||||
CMenuForwarder *m6 = new CMenuForwarder( LOCALE_NETWORKMENU_NTPSERVER, true , g_settings.network_ntpserver, networkSettings_NtpServer );
|
CMenuForwarder *m6 = new CMenuForwarder(LOCALE_NETWORKMENU_NTPSERVER, true , g_settings.network_ntpserver, networkSettings_NtpServer );
|
||||||
CMenuForwarder *m7 = new CMenuForwarder( LOCALE_NETWORKMENU_NTPREFRESH, true , g_settings.network_ntprefresh, networkSettings_NtpRefresh );
|
CMenuForwarder *m7 = new CMenuForwarder(LOCALE_NETWORKMENU_NTPREFRESH, true , g_settings.network_ntprefresh, networkSettings_NtpRefresh );
|
||||||
|
|
||||||
CDHCPNotifier* dhcpNotifier = new CDHCPNotifier(m1,m2,m3,m4,m5);
|
CMenuForwarder *m8 = new CMenuForwarder(LOCALE_NETWORKMENU_HOSTNAME, !networkConfig.inet_static, networkConfig.hostname, networkSettings_Hostname);
|
||||||
|
|
||||||
|
CDHCPNotifier* dhcpNotifier = new CDHCPNotifier(m1,m2,m3,m4,m5, m8);
|
||||||
|
|
||||||
network_automatic_start = networkConfig.automatic_start ? 1 : 0;
|
network_automatic_start = networkConfig.automatic_start ? 1 : 0;
|
||||||
CMenuOptionChooser* oj = new CMenuOptionChooser(LOCALE_NETWORKMENU_SETUPONSTARTUP, &network_automatic_start, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, true);
|
CMenuOptionChooser* oj = new CMenuOptionChooser(LOCALE_NETWORKMENU_SETUPONSTARTUP, &network_automatic_start, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, true);
|
||||||
@@ -1903,6 +1908,7 @@ void CNeutrinoApp::InitNetworkSettings(CMenuWidget &networkSettings)
|
|||||||
network_dhcp = networkConfig.inet_static ? 0 : 1;
|
network_dhcp = networkConfig.inet_static ? 0 : 1;
|
||||||
oj = new CMenuOptionChooser(LOCALE_NETWORKMENU_DHCP, &network_dhcp, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, true, dhcpNotifier);
|
oj = new CMenuOptionChooser(LOCALE_NETWORKMENU_DHCP, &network_dhcp, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, true, dhcpNotifier);
|
||||||
networkSettings.addItem(oj);
|
networkSettings.addItem(oj);
|
||||||
|
networkSettings.addItem(m8);
|
||||||
networkSettings.addItem(GenericMenuSeparatorLine);
|
networkSettings.addItem(GenericMenuSeparatorLine);
|
||||||
|
|
||||||
networkSettings.addItem( m1);
|
networkSettings.addItem( m1);
|
||||||
|
@@ -45,6 +45,8 @@ void CNetworkConfig::init_vars(void)
|
|||||||
char router[16];
|
char router[16];
|
||||||
char ip[16];
|
char ip[16];
|
||||||
|
|
||||||
|
hostname = netGetHostname();
|
||||||
|
|
||||||
netGetDefaultRoute(router);
|
netGetDefaultRoute(router);
|
||||||
gateway = router;
|
gateway = router;
|
||||||
netGetIP((char *) "eth0", ip, mask, _broadcast);
|
netGetIP((char *) "eth0", ip, mask, _broadcast);
|
||||||
@@ -61,6 +63,7 @@ void CNetworkConfig::copy_to_orig(void)
|
|||||||
orig_broadcast = broadcast;
|
orig_broadcast = broadcast;
|
||||||
orig_gateway = gateway;
|
orig_gateway = gateway;
|
||||||
orig_inet_static = inet_static;
|
orig_inet_static = inet_static;
|
||||||
|
orig_hostname = hostname;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CNetworkConfig::modified_from_orig(void)
|
bool CNetworkConfig::modified_from_orig(void)
|
||||||
@@ -71,6 +74,7 @@ bool CNetworkConfig::modified_from_orig(void)
|
|||||||
(orig_netmask != netmask ) ||
|
(orig_netmask != netmask ) ||
|
||||||
(orig_broadcast != broadcast ) ||
|
(orig_broadcast != broadcast ) ||
|
||||||
(orig_gateway != gateway ) ||
|
(orig_gateway != gateway ) ||
|
||||||
|
(orig_hostname != hostname ) ||
|
||||||
(orig_inet_static != inet_static )
|
(orig_inet_static != inet_static )
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -79,6 +83,9 @@ void CNetworkConfig::commitConfig(void)
|
|||||||
{
|
{
|
||||||
if (modified_from_orig())
|
if (modified_from_orig())
|
||||||
{
|
{
|
||||||
|
if(orig_hostname != hostname)
|
||||||
|
netSetHostname((char *) hostname.c_str());
|
||||||
|
|
||||||
copy_to_orig();
|
copy_to_orig();
|
||||||
|
|
||||||
if (inet_static)
|
if (inet_static)
|
||||||
|
@@ -33,6 +33,7 @@ class CNetworkConfig
|
|||||||
std::string orig_broadcast;
|
std::string orig_broadcast;
|
||||||
std::string orig_gateway;
|
std::string orig_gateway;
|
||||||
std::string orig_nameserver;
|
std::string orig_nameserver;
|
||||||
|
std::string orig_hostname;
|
||||||
bool orig_inet_static;
|
bool orig_inet_static;
|
||||||
|
|
||||||
void copy_to_orig(void);
|
void copy_to_orig(void);
|
||||||
@@ -46,6 +47,7 @@ class CNetworkConfig
|
|||||||
std::string broadcast;
|
std::string broadcast;
|
||||||
std::string gateway;
|
std::string gateway;
|
||||||
std::string nameserver;
|
std::string nameserver;
|
||||||
|
std::string hostname;
|
||||||
bool inet_static;
|
bool inet_static;
|
||||||
|
|
||||||
CNetworkConfig(void);
|
CNetworkConfig(void);
|
||||||
|
@@ -767,6 +767,7 @@ typedef enum {
|
|||||||
LOCALE_NETWORKMENU_DHCP,
|
LOCALE_NETWORKMENU_DHCP,
|
||||||
LOCALE_NETWORKMENU_GATEWAY,
|
LOCALE_NETWORKMENU_GATEWAY,
|
||||||
LOCALE_NETWORKMENU_HEAD,
|
LOCALE_NETWORKMENU_HEAD,
|
||||||
|
LOCALE_NETWORKMENU_HOSTNAME,
|
||||||
LOCALE_NETWORKMENU_IPADDRESS,
|
LOCALE_NETWORKMENU_IPADDRESS,
|
||||||
LOCALE_NETWORKMENU_MOUNT,
|
LOCALE_NETWORKMENU_MOUNT,
|
||||||
LOCALE_NETWORKMENU_NAMESERVER,
|
LOCALE_NETWORKMENU_NAMESERVER,
|
||||||
|
@@ -767,6 +767,7 @@ const char *locale_real_names[] = {
|
|||||||
"networkmenu.dhcp",
|
"networkmenu.dhcp",
|
||||||
"networkmenu.gateway",
|
"networkmenu.gateway",
|
||||||
"networkmenu.head",
|
"networkmenu.head",
|
||||||
|
"networkmenu.hostname",
|
||||||
"networkmenu.ipaddress",
|
"networkmenu.ipaddress",
|
||||||
"networkmenu.mount",
|
"networkmenu.mount",
|
||||||
"networkmenu.nameserver",
|
"networkmenu.nameserver",
|
||||||
|
@@ -206,13 +206,14 @@ bool CTP_scanNotifier::changeNotify(const neutrino_locale_t, void * Data)
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
CDHCPNotifier::CDHCPNotifier( CMenuForwarder* a1, CMenuForwarder* a2, CMenuForwarder* a3, CMenuForwarder* a4, CMenuForwarder* a5)
|
CDHCPNotifier::CDHCPNotifier( CMenuForwarder* a1, CMenuForwarder* a2, CMenuForwarder* a3, CMenuForwarder* a4, CMenuForwarder* a5, CMenuForwarder* a6)
|
||||||
{
|
{
|
||||||
toDisable[0] = a1;
|
toDisable[0] = a1;
|
||||||
toDisable[1] = a2;
|
toDisable[1] = a2;
|
||||||
toDisable[2] = a3;
|
toDisable[2] = a3;
|
||||||
toDisable[3] = a4;
|
toDisable[3] = a4;
|
||||||
toDisable[4] = a5;
|
toDisable[4] = a5;
|
||||||
|
toEnable[0] = a6;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -221,6 +222,8 @@ bool CDHCPNotifier::changeNotify(const neutrino_locale_t, void * data)
|
|||||||
CNeutrinoApp::getInstance()->networkConfig.inet_static = ((*(int*)(data)) == 0);
|
CNeutrinoApp::getInstance()->networkConfig.inet_static = ((*(int*)(data)) == 0);
|
||||||
for(int x=0;x<5;x++)
|
for(int x=0;x<5;x++)
|
||||||
toDisable[x]->setActive(CNeutrinoApp::getInstance()->networkConfig.inet_static);
|
toDisable[x]->setActive(CNeutrinoApp::getInstance()->networkConfig.inet_static);
|
||||||
|
|
||||||
|
toEnable[0]->setActive(!CNeutrinoApp::getInstance()->networkConfig.inet_static);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -82,10 +82,12 @@ class CDHCPNotifier : public CChangeObserver
|
|||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
CMenuForwarder* toDisable[5];
|
CMenuForwarder* toDisable[5];
|
||||||
|
CMenuForwarder* toEnable[1];
|
||||||
public:
|
public:
|
||||||
CDHCPNotifier( CMenuForwarder*, CMenuForwarder*, CMenuForwarder*, CMenuForwarder*, CMenuForwarder*);
|
CDHCPNotifier( CMenuForwarder*, CMenuForwarder*, CMenuForwarder*, CMenuForwarder*, CMenuForwarder*, CMenuForwarder*);
|
||||||
bool changeNotify(const neutrino_locale_t, void * data);
|
bool changeNotify(const neutrino_locale_t, void * data);
|
||||||
};
|
};
|
||||||
|
|
||||||
class CStreamingNotifier : public CChangeObserver
|
class CStreamingNotifier : public CChangeObserver
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
Reference in New Issue
Block a user