mirror of
https://github.com/rancher/os.git
synced 2025-09-14 22:20:35 +00:00
Add 4glte support
This commit is contained in:
@@ -1,20 +1,61 @@
|
||||
package control
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/rancher/os/config"
|
||||
"github.com/rancher/os/pkg/log"
|
||||
|
||||
"github.com/codegangsta/cli"
|
||||
)
|
||||
|
||||
func udevSettleAction(c *cli.Context) {
|
||||
if err := extraRules(); err != nil {
|
||||
log.Error(err)
|
||||
}
|
||||
|
||||
if err := UdevSettle(); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func extraRules() error {
|
||||
cfg := config.LoadConfig()
|
||||
if len(cfg.Rancher.Network.ModemNetworks) > 0 {
|
||||
rules, err := ioutil.ReadDir(config.UdevRulesExtrasDir)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, r := range rules {
|
||||
if r.IsDir() || filepath.Ext(r.Name()) != ".rules" {
|
||||
continue
|
||||
}
|
||||
err := os.Symlink(filepath.Join(config.UdevRulesExtrasDir, r.Name()), filepath.Join(config.UdevRulesDir, r.Name()))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
} else {
|
||||
rules, err := ioutil.ReadDir(config.UdevRulesDir)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, r := range rules {
|
||||
if r.IsDir() || (filepath.Ext(r.Name()) != ".rules") || (r.Mode()&os.ModeSymlink != 0) {
|
||||
continue
|
||||
}
|
||||
err := os.Remove(filepath.Join(config.UdevRulesDir, r.Name()))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func UdevSettle() error {
|
||||
cmd := exec.Command("udevd", "--daemon")
|
||||
defer exec.Command("killall", "udevd").Run()
|
||||
|
@@ -58,7 +58,6 @@ func RunInit() error {
|
||||
{"mount OEM2", fsmount.MountOem},
|
||||
{"mount BOOT", fsmount.MountBoot},
|
||||
{"write cfg and log files", configfiles.WriteConfigFiles},
|
||||
{"hypervisor Env", hypervisor.Env},
|
||||
{"b2d Env", b2d.Env},
|
||||
{"hypervisor tools", hypervisor.Tools},
|
||||
{"preparefs2", prepare.FS},
|
||||
|
@@ -88,7 +88,8 @@ var schema = `{
|
||||
"http_proxy": {"type": "string"},
|
||||
"https_proxy": {"type": "string"},
|
||||
"no_proxy": {"type": "string"},
|
||||
"wifi_networks": {"type": "object"}
|
||||
"wifi_networks": {"type": "object"},
|
||||
"modem_networks": {"type": "array"}
|
||||
}
|
||||
},
|
||||
|
||||
|
@@ -53,6 +53,8 @@ const (
|
||||
DHCPCDTemplateFile = "/etc/dhcpcd.conf.tpl"
|
||||
MultiDockerConfFile = "/var/lib/rancher/conf.d/m-user-docker.yml"
|
||||
MultiDockerDataDir = "/var/lib/m-user-docker"
|
||||
UdevRulesDir = "/etc/udev/rules.d"
|
||||
UdevRulesExtrasDir = "/lib/udev/rules-extras.d"
|
||||
)
|
||||
|
||||
var (
|
||||
|
@@ -1,9 +1,6 @@
|
||||
package hypervisor
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
|
||||
"github.com/rancher/os/config"
|
||||
"github.com/rancher/os/pkg/log"
|
||||
"github.com/rancher/os/pkg/util"
|
||||
@@ -14,38 +11,6 @@ func Tools(cfg *config.CloudConfig) (*config.CloudConfig, error) {
|
||||
return config.LoadConfig(), nil
|
||||
}
|
||||
|
||||
func Env(cfg *config.CloudConfig) (*config.CloudConfig, error) {
|
||||
hypervisor := util.GetHypervisor()
|
||||
|
||||
// this code make sure the open-vm-tools service can be started correct when there is no network
|
||||
if hypervisor == "vmware" {
|
||||
// make sure the cache directory exist
|
||||
if err := os.MkdirAll("/var/lib/rancher/cache/", os.ModeDir|0755); err != nil {
|
||||
log.Errorf("Create service cache diretory error: %v", err)
|
||||
}
|
||||
|
||||
// move os-services cache file
|
||||
if _, err := os.Stat("/usr/share/ros/services-cache"); err == nil {
|
||||
files, err := ioutil.ReadDir("/usr/share/ros/services-cache/")
|
||||
if err != nil {
|
||||
log.Errorf("Read file error: %v", err)
|
||||
}
|
||||
for _, f := range files {
|
||||
err := os.Rename("/usr/share/ros/services-cache/"+f.Name(), "/var/lib/rancher/cache/"+f.Name())
|
||||
if err != nil {
|
||||
log.Errorf("Rename file error: %v", err)
|
||||
}
|
||||
}
|
||||
if err := os.Remove("/usr/share/ros/services-cache"); err != nil {
|
||||
log.Errorf("Remove file error: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return cfg, nil
|
||||
}
|
||||
|
||||
func enableHypervisorService(cfg *config.CloudConfig, hypervisorName string) {
|
||||
if hypervisorName == "" {
|
||||
return
|
||||
|
@@ -1,15 +1,16 @@
|
||||
package netconf
|
||||
|
||||
type NetworkConfig struct {
|
||||
PreCmds []string `yaml:"pre_cmds,omitempty"`
|
||||
DHCPTimeout int `yaml:"dhcp_timeout,omitempty"`
|
||||
DNS DNSConfig `yaml:"dns,omitempty"`
|
||||
Interfaces map[string]InterfaceConfig `yaml:"interfaces,omitempty"`
|
||||
PostCmds []string `yaml:"post_cmds,omitempty"`
|
||||
HTTPProxy string `yaml:"http_proxy,omitempty"`
|
||||
HTTPSProxy string `yaml:"https_proxy,omitempty"`
|
||||
NoProxy string `yaml:"no_proxy,omitempty"`
|
||||
WifiNetworks map[string]WifiNetworkConfig `yaml:"wifi_networks,omitempty"`
|
||||
PreCmds []string `yaml:"pre_cmds,omitempty"`
|
||||
DHCPTimeout int `yaml:"dhcp_timeout,omitempty"`
|
||||
DNS DNSConfig `yaml:"dns,omitempty"`
|
||||
Interfaces map[string]InterfaceConfig `yaml:"interfaces,omitempty"`
|
||||
PostCmds []string `yaml:"post_cmds,omitempty"`
|
||||
HTTPProxy string `yaml:"http_proxy,omitempty"`
|
||||
HTTPSProxy string `yaml:"https_proxy,omitempty"`
|
||||
NoProxy string `yaml:"no_proxy,omitempty"`
|
||||
WifiNetworks map[string]WifiNetworkConfig `yaml:"wifi_networks,omitempty"`
|
||||
ModemNetworks []ModemNetworkConfig `yaml:"modem_networks,omitempty"`
|
||||
}
|
||||
|
||||
type InterfaceConfig struct {
|
||||
@@ -57,3 +58,9 @@ type WifiNetworkConfig struct {
|
||||
KeyMgmt string `yaml:"key_mgmt,omitempty"`
|
||||
Password string `yaml:"password,omitempty"`
|
||||
}
|
||||
|
||||
type ModemNetworkConfig struct {
|
||||
Apn string `yaml:"apn"`
|
||||
Interface string `yaml:"interface"`
|
||||
ExtraArgs string `yaml:"extra_args,omitempty"`
|
||||
}
|
||||
|
@@ -2,6 +2,7 @@ package sysinit
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path"
|
||||
@@ -124,7 +125,33 @@ func SysInit() error {
|
||||
return err
|
||||
}
|
||||
|
||||
func loadServicesCache() {
|
||||
// this code make sure the open-vm-tools, modem-manager... services can be started correct when there is no network
|
||||
// make sure the cache directory exist
|
||||
if err := os.MkdirAll("/var/lib/rancher/cache/", os.ModeDir|0755); err != nil {
|
||||
log.Errorf("Create service cache diretory error: %v", err)
|
||||
}
|
||||
|
||||
// move os-services cache file
|
||||
if _, err := os.Stat("/usr/share/ros/services-cache"); err == nil {
|
||||
files, err := ioutil.ReadDir("/usr/share/ros/services-cache/")
|
||||
if err != nil {
|
||||
log.Errorf("Read file error: %v", err)
|
||||
}
|
||||
for _, f := range files {
|
||||
err := os.Rename("/usr/share/ros/services-cache/"+f.Name(), "/var/lib/rancher/cache/"+f.Name())
|
||||
if err != nil {
|
||||
log.Errorf("Rename file error: %v", err)
|
||||
}
|
||||
}
|
||||
if err := os.Remove("/usr/share/ros/services-cache"); err != nil {
|
||||
log.Errorf("Remove file error: %v", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func RunSysInit(c *config.CloudConfig) (*config.CloudConfig, error) {
|
||||
loadServicesCache()
|
||||
args := append([]string{config.SysInitBin}, os.Args[1:]...)
|
||||
|
||||
cmd := &exec.Cmd{
|
||||
|
Reference in New Issue
Block a user