https://github.com/jirutka/one-context
OpenNebula contextualization scripts for Alpine Linux and Gentoo
https://github.com/jirutka/one-context
alpine-linux linux opennebula openrc
Last synced: about 1 year ago
JSON representation
OpenNebula contextualization scripts for Alpine Linux and Gentoo
- Host: GitHub
- URL: https://github.com/jirutka/one-context
- Owner: jirutka
- License: mit
- Created: 2016-04-19T23:00:54.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2023-10-05T21:36:07.000Z (over 2 years ago)
- Last Synced: 2025-04-15T00:18:28.862Z (about 1 year ago)
- Topics: alpine-linux, linux, opennebula, openrc
- Language: Shell
- Homepage:
- Size: 55.7 KB
- Stars: 4
- Watchers: 2
- Forks: 3
- Open Issues: 2
-
Metadata Files:
- Readme: README.adoc
- License: LICENSE
Awesome Lists containing this project
README
= OpenNebula Contextualization / OpenRC
:proj-name: one-context
:gh-name: jirutka/{proj-name}
This project provides “contextualization” scripts for https://alpinelinux.org[Alpine Linux] virtual machines running on http://opennebula.org[OpenNebula].
The scripts are inspired by the official scripts from https://github.com/OpenNebula/addon-context-linux[addon-context-linux], but rewritten from scratch to be more readable, robust and fully POSIX compatible.
This is _not_ yet another fork of these poor official scripts.
*NOTE:* Support for Gentoo has been removed in version 0.8.0. If you miss it, please let me know in the issues.
== Scripts
=== link:scripts/network[00-network]
Configures network interfaces (via `/etc/network/interfaces`) and (re)starts the networking service, if `**$NETWORK**` is `YES`.
It supports the following variables:
* `**$DNS**` -- DNS servers (as space-separated addressess).
* `**$SEARCH_DOMAIN**` -- The domain search list.
* `**$ETH_MAC**` -- Used to find the correct interface by MAC address.
* `**$ETH_IP**` -- IPv4 address for the interface.
* `**$ETH_MASK**` -- IPv4 network mask for the interface.
* `**$ETH_GATEWAY**` -- Default IPv4 gateway for the interface.
* `**$ETH_IP6**` (or legacy `**$ETH_IPV6**`) -- IPv6 address for the interface.
* `**$ETH_IP6_GATEWAY**` (or legacy `**$ETH_GATEWAY6**`) -- Default IPv6 gateway for the interface.
* `**$ETH_DNS**` -- DNS servers for the network (as space-separated addressess).
* `**$ETH_SEARCH_DOMAIN**` -- The domain search list for the network.
=== link:scripts/hostname[05-hostname]
Sets the hostname to `**$SET_HOSTNAME**`, if provided.
It should contain only alphanumeric ASCII characters and a hyphen (`[a-zA-Z0-9-]`), all other characters will be replaced with a hyphen (`-`).
=== link:scripts/hosts[10-hosts]
Adds the following lines to `/etc/hosts`:
[source, subs="+quotes"]
127.0.0.1 __ __ localhost
::1 __ __ localhost
`____` is `**$SET_FQDN**` or, if not provided, `**$SET_HOSTNAME**`.
It should contain only alphanumeric characters, a hyphen and a period (`[a-zA-Z0-9.-]`), all other characters will be replaced with a hyphen (`-`).
`____` is the system’s hostname (previously set to `**$SET_HOSTNAME**`).
=== link:scripts/ntp[15-ntp]
Adds NTP servers specified in `**$NTP**` (as space-seperated addressess) to either `/etc/ntpd.conf` (OpenNTPD) or `/etc/ntp.conf` (ISC ntp), if `**$NTP**` is provided.
=== link:scripts/timezone[20-timezone]
Changes the system timezone to `**$TIMEZONE**` (e.g. `Europe/Prague`, `UTC`), if provided.
=== link:scripts/sudo-user[50-sudo-user]
Creates an user account named `**$USERNAME**` with primary group `users`, secondary group `wheel`, and shell `**$USERNAME_SHELL**` (defaults to `/bin/sh`).
If `**$USERNAME_SUDO**` isn’t provided or it’s `YES`, it also creates a `doas` or `sudo` (if `doas` is not installed) rule in `/etc/doas.d/wheel.conf` or `/etc/sudoers.d/wheel`, respectively, to permit the created user to run any command as any user (i.e. gives them the root access).
If `**$USERNAME**` is not provided, this script is skipped.
=== link:scripts/ssh-public-key[55-ssh-public-key]
Adds an SSH public key provided in `**$SSH_PUBLIC_KEY**` to `authorized_keys` of the user specified by `**$USERNAME**` (or `root` if not set), if `**$SSH_PUBLIC_KEY**` is provided.
=== link:scripts/grow-fs[60-grow-fs]
Extends all mounted filesystems to the maximum disk capacity, unless `**$GROWFS_DISABLE**` is `YES`.
Only ext3, ext4, and btrfs are currently supported.
If the filesystem resides on a partition (GPT or DOS) and it’s the last partition, it will be expanded before resizing the filesystem.
*Note*: It’s completely unnecessary and pointless to use partitions on virtual disks, it just adds more complexity and complications, but some broken platforms and tools require it.
=== link:scripts/ssmtp[65-ssmtp]
Updates `/etc/ssmtp/ssmtp.conf`, if exists:
* `Root` to `**$ROOT_EMAIL**` (if provided)
* `Mailhub` to `**$SMTP**` (if provided)
=== link:scripts/start-script[90-start-script]
Executes the script provided in `**$START_SCRIPT_BASE64**` (base64-encoded) or `**$START_SCRIPT**`.
If the script doesn’t start with a shebang, it’s executed with /bin/sh.
== Requirements
* POSIX-compatible shell (e.g. ash, bash, dash)
* core *nix utils (`awk`, `grep`, `sed`...)
* https://wiki.gentoo.org/wiki/OpenRC[OpenRC]
* blkid from https://git.kernel.org/pub/scm/utils/util-linux/util-linux.git[util-linux] (for OpenRC runscript)
* btrfs utility and/or resize2fs from http://e2fsprogs.sourceforge.net[e2fsprogs] (only for growfs script)
* `partx` and `sfdisk` from https://git.kernel.org/pub/scm/utils/util-linux/util-linux.git[util-linux] (only for grow-fs script if you use partitions)
* `ifup` (only for network scripts)
* kernel with support for mounting CD-ROM with ISO 9660 filesystem footnote:[This is the way how OpenNebula passes configuration variables into VM.]
== Installation
=== Alpine Linux
. Install https://pkgs.alpinelinux.org/packages?name={proj-name}[{proj-name}] from the Alpine’s main repository:
+
[source, sh, subs="+attributes"]
apk add {proj-name}
=== Manually
. Clone this repository and jump in:
+
[source, sh, subs="+attributes"]
git clone https://github.com/{gh-name}.git
cd one-context
. Install init script, contextualization scripts and symlinks (you may need to run this with sudo)…
+
[source, sh]
make install
+
You may use variables `DESTDIR` and `PREFIX` to specify the target directories.
. `rc-update add vmcontext boot`
=== Directory Structure
The scripts are installed into `/usr/share/one-context/scripts` (depends on `DESTDIR` and `PREFIX` variables, see above) and symlinked into `/etc/one-context.d` with a numeric prefix to specify the execution order.
The runscript is installed into `/etc/init.d/vmcontext`.
== License
This project is licensed under http://opensource.org/licenses/MIT/[MIT License].