SmartOS global zone customization

Most folders in SmartOS global zone are read only because they are stored in memory. But there is still the possibility to customize the boot process and the global zone.

For that you could create a folder /opt/custom. All SMF manifests in the sub directory smf will be loaded on boot. Because I'm not the SMF manifest master i decided to create one small SMF file that loads all other scripts via bash.

I created the following /opt structure. That allow me to provide config files and boot scripts for different data centers or servers.

.
├── custom
│   ├── cfg
│   │   ├── datacenter
│   │   ├── global
│   │   │   ├── crontab
│   │   │   │   ├── fmadm
│   │   │   │   └── zpool
│   │   │   ├── root
│   │   │   │   └── root
│   │   │   └── script
│   │   │       ├── 10-hostname.sh
│   │   │       ├── 15-ipv6.sh
│   │   │       └── 20-sendmail.sh
│   │   └── host
│   │       ├── 8c-89-a5-63-b8-ed
│   │       │   ├── root
│   │       │   │   ├── etc
│   │       │   │   │   └── ipf
│   │       │   │   │       ├── ipf.conf
│   │       │   │   │       └── ipnat.conf
│   │       │   │   └── root
│   │       │   │       └── ssh
│   │       │   │           ├── id_rsa
│   │       │   │           └── id_rsa.pub
│   │       │   └── script
│   │       │       └── 10-network.sh
│   ├── script
│   │   └── postboot.sh
│   └── smf
│       └── postboot.xml
└── local
    └── sbin
        └── zrep

SmartOS run the /opt/custom/smf/postboot.xml at boot, after network setup because it's configured in the manifest file. The SMF file call the /opt/custom/script/postboot.sh bash script.

The cfg folder has three types:

  • global, will be executed on all servers
  • datacenter, depends on the datacenter name the server is located
  • host, depends on the host name of the server

In each cfg-type folder we have three other folders for the setup:

  • crontabs, contains jobs that should be added to the root crontab
  • root, deploy all files and folders to / (overwrite all)
  • script, will be executed

The full source could be found on GitHub. It already contains scripts for:

Posted

December 27, 2013, 4:48 pm

Tags

, , , , ,

More

Permalink

Comments

Send your comment by mail.