forked from lxcafe/lxcafe
bc1e17ec04
* documentation added * scripts to setup image and start container added
61 lines
1.9 KiB
Markdown
61 lines
1.9 KiB
Markdown
# Post-Installation Script Testing
|
|
|
|
This directory contains everything needed to test the post-installation script in a safe, isolated container environment.
|
|
|
|
## Contents
|
|
|
|
- `Dockerfile` - Container image definition for testing
|
|
- `01_create_image.sh` - script for creating container image locally
|
|
- `02_start_container_with_image.sh` - script for starting container from created image
|
|
|
|
## Purpose
|
|
|
|
Provides a reproducible testing environment that allows:
|
|
|
|
- Running the post-installation script without affecting the host system
|
|
- Simulating `apt` installations (safe, no real package changes)
|
|
- Testing script logic, prompts, and error handling
|
|
- Validating syntax and tracing execution
|
|
|
|
## Features
|
|
|
|
The Dockerfile includes:
|
|
|
|
- Ubuntu 22.04 base image
|
|
- Simulated `sudo` wrapper that runs `apt-get -s install` (simulates installs without making changes)
|
|
- Useful utilities: `bash`, `wget`, `tar`, `curl`, `gnupg`, `ca-certificates`, `file`, `procps`
|
|
|
|
## Usage
|
|
|
|
### Build the test image
|
|
Run the prepared shell script to build the image
|
|
|
|
```bash
|
|
cd post_installation_script_test
|
|
sh 01_create_image.sh
|
|
```
|
|
|
|
### Start a container for testing
|
|
Run the prepared shell script start a new container for testing based in the
|
|
image and remove container after it is stopped. After container is started an interactive session is started into the container.
|
|
|
|
```bash
|
|
cd post_installation_script_test
|
|
sh 02_start_container_with_image.sh
|
|
```
|
|
|
|
|
|
### Test the script file in the running container
|
|
After container is started an interactive session was started in the container and the script can be started for testing
|
|
|
|
```bash
|
|
sh script.sh
|
|
```
|
|
|
|
## Security Notes
|
|
|
|
- The script is mounted read-only (`:ro` flag) to prevent container from modifying host files
|
|
- Container runs with reduced privileges (`--cap-drop ALL --security-opt no-new-privileges`)
|
|
- The `sudo` wrapper simulates apt operations, so no packages are actually installed
|
|
- Use `--tmpfs /tmp:rw` for any temporary writes inside the container
|