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
|
package control
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
"path/filepath"
|
||||||
|
|
||||||
|
"github.com/rancher/os/config"
|
||||||
"github.com/rancher/os/pkg/log"
|
"github.com/rancher/os/pkg/log"
|
||||||
|
|
||||||
"github.com/codegangsta/cli"
|
"github.com/codegangsta/cli"
|
||||||
)
|
)
|
||||||
|
|
||||||
func udevSettleAction(c *cli.Context) {
|
func udevSettleAction(c *cli.Context) {
|
||||||
|
if err := extraRules(); err != nil {
|
||||||
|
log.Error(err)
|
||||||
|
}
|
||||||
|
|
||||||
if err := UdevSettle(); err != nil {
|
if err := UdevSettle(); err != nil {
|
||||||
log.Fatal(err)
|
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 {
|
func UdevSettle() error {
|
||||||
cmd := exec.Command("udevd", "--daemon")
|
cmd := exec.Command("udevd", "--daemon")
|
||||||
defer exec.Command("killall", "udevd").Run()
|
defer exec.Command("killall", "udevd").Run()
|
||||||
|
@@ -58,7 +58,6 @@ func RunInit() error {
|
|||||||
{"mount OEM2", fsmount.MountOem},
|
{"mount OEM2", fsmount.MountOem},
|
||||||
{"mount BOOT", fsmount.MountBoot},
|
{"mount BOOT", fsmount.MountBoot},
|
||||||
{"write cfg and log files", configfiles.WriteConfigFiles},
|
{"write cfg and log files", configfiles.WriteConfigFiles},
|
||||||
{"hypervisor Env", hypervisor.Env},
|
|
||||||
{"b2d Env", b2d.Env},
|
{"b2d Env", b2d.Env},
|
||||||
{"hypervisor tools", hypervisor.Tools},
|
{"hypervisor tools", hypervisor.Tools},
|
||||||
{"preparefs2", prepare.FS},
|
{"preparefs2", prepare.FS},
|
||||||
|
@@ -88,7 +88,8 @@ var schema = `{
|
|||||||
"http_proxy": {"type": "string"},
|
"http_proxy": {"type": "string"},
|
||||||
"https_proxy": {"type": "string"},
|
"https_proxy": {"type": "string"},
|
||||||
"no_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"
|
DHCPCDTemplateFile = "/etc/dhcpcd.conf.tpl"
|
||||||
MultiDockerConfFile = "/var/lib/rancher/conf.d/m-user-docker.yml"
|
MultiDockerConfFile = "/var/lib/rancher/conf.d/m-user-docker.yml"
|
||||||
MultiDockerDataDir = "/var/lib/m-user-docker"
|
MultiDockerDataDir = "/var/lib/m-user-docker"
|
||||||
|
UdevRulesDir = "/etc/udev/rules.d"
|
||||||
|
UdevRulesExtrasDir = "/lib/udev/rules-extras.d"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@@ -1,9 +1,6 @@
|
|||||||
package hypervisor
|
package hypervisor
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"github.com/rancher/os/config"
|
"github.com/rancher/os/config"
|
||||||
"github.com/rancher/os/pkg/log"
|
"github.com/rancher/os/pkg/log"
|
||||||
"github.com/rancher/os/pkg/util"
|
"github.com/rancher/os/pkg/util"
|
||||||
@@ -14,38 +11,6 @@ func Tools(cfg *config.CloudConfig) (*config.CloudConfig, error) {
|
|||||||
return config.LoadConfig(), nil
|
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) {
|
func enableHypervisorService(cfg *config.CloudConfig, hypervisorName string) {
|
||||||
if hypervisorName == "" {
|
if hypervisorName == "" {
|
||||||
return
|
return
|
||||||
|
@@ -1,15 +1,16 @@
|
|||||||
package netconf
|
package netconf
|
||||||
|
|
||||||
type NetworkConfig struct {
|
type NetworkConfig struct {
|
||||||
PreCmds []string `yaml:"pre_cmds,omitempty"`
|
PreCmds []string `yaml:"pre_cmds,omitempty"`
|
||||||
DHCPTimeout int `yaml:"dhcp_timeout,omitempty"`
|
DHCPTimeout int `yaml:"dhcp_timeout,omitempty"`
|
||||||
DNS DNSConfig `yaml:"dns,omitempty"`
|
DNS DNSConfig `yaml:"dns,omitempty"`
|
||||||
Interfaces map[string]InterfaceConfig `yaml:"interfaces,omitempty"`
|
Interfaces map[string]InterfaceConfig `yaml:"interfaces,omitempty"`
|
||||||
PostCmds []string `yaml:"post_cmds,omitempty"`
|
PostCmds []string `yaml:"post_cmds,omitempty"`
|
||||||
HTTPProxy string `yaml:"http_proxy,omitempty"`
|
HTTPProxy string `yaml:"http_proxy,omitempty"`
|
||||||
HTTPSProxy string `yaml:"https_proxy,omitempty"`
|
HTTPSProxy string `yaml:"https_proxy,omitempty"`
|
||||||
NoProxy string `yaml:"no_proxy,omitempty"`
|
NoProxy string `yaml:"no_proxy,omitempty"`
|
||||||
WifiNetworks map[string]WifiNetworkConfig `yaml:"wifi_networks,omitempty"`
|
WifiNetworks map[string]WifiNetworkConfig `yaml:"wifi_networks,omitempty"`
|
||||||
|
ModemNetworks []ModemNetworkConfig `yaml:"modem_networks,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type InterfaceConfig struct {
|
type InterfaceConfig struct {
|
||||||
@@ -57,3 +58,9 @@ type WifiNetworkConfig struct {
|
|||||||
KeyMgmt string `yaml:"key_mgmt,omitempty"`
|
KeyMgmt string `yaml:"key_mgmt,omitempty"`
|
||||||
Password string `yaml:"password,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 (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path"
|
"path"
|
||||||
@@ -124,7 +125,33 @@ func SysInit() error {
|
|||||||
return err
|
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) {
|
func RunSysInit(c *config.CloudConfig) (*config.CloudConfig, error) {
|
||||||
|
loadServicesCache()
|
||||||
args := append([]string{config.SysInitBin}, os.Args[1:]...)
|
args := append([]string{config.SysInitBin}, os.Args[1:]...)
|
||||||
|
|
||||||
cmd := &exec.Cmd{
|
cmd := &exec.Cmd{
|
||||||
|
Reference in New Issue
Block a user