https://github.com/null93/mirdir
CLI tool that mirrors and templates a directory structure
https://github.com/null93/mirdir
cli golang templates
Last synced: 2 months ago
JSON representation
CLI tool that mirrors and templates a directory structure
- Host: GitHub
- URL: https://github.com/null93/mirdir
- Owner: null93
- License: mit
- Created: 2024-03-01T04:58:37.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2024-03-20T03:50:28.000Z (about 2 years ago)
- Last Synced: 2025-01-01T00:22:47.544Z (over 1 year ago)
- Topics: cli, golang, templates
- Language: Go
- Homepage:
- Size: 17.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# mirdir (mirror directory)
> CLI tool that mirrors and templates a directory structure
## About
`mirdir` is a command-line tool written in Go that allows you to copy a folder and mirror all the files from a source directory (`TPL_DIR`) to a destination directory (`DST_DIR`). One of the key features of `mirdir` is its ability to process files ending in `.tpl` as Go templates. This allows you to use the powerful templating features of Go to generate content in your destination files.
The tool also provides several optional flags, including one to preserve file ownership and permissions from the source directory, another is to delete blank files that are generated in the destination directory. Finally there is a 'dry run' flag that allows you to preview the changes that would be made without actually applying them.
## Install
Darwin
### Intel & ARM
```shell
brew tap null93/tap
brew install mirdir
```
Debian
### amd64
```shell
curl -sL -o ./mirdir_0.0.1_amd64.deb https://github.com/null93/mirdir/releases/download/0.0.1/mirdir_0.0.1_amd64.deb
sudo dpkg -i ./mirdir_0.0.1_amd64.deb
rm ./mirdir_0.0.1_amd64.deb
```
### arm64
```shell
curl -sL -o ./mirdir_0.0.1_arm64.deb https://github.com/null93/mirdir/releases/download/0.0.1/mirdir_0.0.1_arm64.deb
sudo dpkg -i ./mirdir_0.0.1_arm64.deb
rm ./mirdir_0.0.1_arm64.deb
```
Red Hat
### aarch64
```shell
rpm -i https://github.com/null93/mirdir/releases/download/0.0.1/mirdir-0.0.1-1.aarch64.rpm
```
### x86_64
```shell
rpm -i https://github.com/null93/mirdir/releases/download/0.0.1/mirdir-0.0.1-1.x86_64.rpm
```
Alpine
### aarch64
```shell
curl -sL -o ./mirdir_0.0.1_aarch64.apk https://github.com/null93/mirdir/releases/download/0.0.1/mirdir_0.0.1_aarch64.apk
apk add --allow-untrusted ./mirdir_0.0.1_aarch64.apk
rm ./mirdir_0.0.1_aarch64.apk
```
### x86_64
```shell
curl -sL -o ./mirdir_0.0.1_x86_64.apk https://github.com/null93/mirdir/releases/download/0.0.1/mirdir_0.0.1_x86_64.apk
apk add --allow-untrusted ./mirdir_0.0.1_x86_64.apk
rm ./mirdir_0.0.1_x86_64.apk
```
Arch
### aarch64
```shell
curl -sL -o ./mirdir-0.0.1-1-aarch64.pkg.tar.zst https://github.com/null93/mirdir/releases/download/0.0.1/mirdir-0.0.1-1-aarch64.pkg.tar.zst
sudo pacman -U ./mirdir-0.0.1-1-aarch64.pkg.tar.zst
rm ./mirdir-0.0.1-1-aarch64.pkg.tar.zst
```
### x86_64
```shell
curl -sL -o ./mirdir-0.0.1-1-x86_64.pkg.tar.zst https://github.com/null93/mirdir/releases/download/0.0.1/mirdir-0.0.1-1-x86_64.pkg.tar.zst
sudo pacman -U ./mirdir-0.0.1-1-x86_64.pkg.tar.zst
rm ./mirdir-0.0.1-1-x86_64.pkg.tar.zst
```
## Usage
```shell
$ tree /opt/confs/nginx
/opt/confs/nginx
├── conf.d
│ ├── bar.conf
│ ├── baz.conf
│ └── foo.conf
├── nginx.conf
├── sites-available
│ └── custom-site-[USER].conf.tpl
└── sites-enabled
└── custom-site-[USER].conf -> ../sites-available/custom-site-[USER].conf
4 directories, 6 files
```
```shell
$ mirdir /opt/confs/nginx/ /etc/nginx/
```
```shell
$ tree /etc/nginx
/etc/nginx
├── conf.d
│ ├── bar.conf
│ ├── baz.conf
│ └── foo.conf
├── nginx.conf
├── sites-available
│ └── custom-site-raffi.conf
└── sites-enabled
└── custom-site-raffi.conf -> ../sites-available/custom-site-raffi.conf
4 directories, 6 files
```
```shell
$ mirdir /opt/confs/nginx/ /etc/nginx/ --dry-run
-rwxrwxrwx 501:20 /etc/nginx/
-rwxrwxrwx 501:20 /etc/nginx/conf.d/
-rwxrwxrwx 501:20 /etc/nginx/sites-available/
-rwxrwxrwx 501:20 /etc/nginx/sites-enabled/
-rw-rw-rw- 501:20 /etc/nginx/conf.d/bar.conf
add_header X-Bar "bar";
-rw-rw-rw- 501:20 /etc/nginx/conf.d/baz.conf
add_header X-Baz "baz";
-rw-rw-rw- 501:20 /etc/nginx/conf.d/foo.conf
add_header X-Foo "foo";
-rw-rw-rw- 501:20 /etc/nginx/nginx.conf
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log notice;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
default_type application/octet-stream;
include ./sites-enabled/*.conf;
server {
listen 80;
server_name _;
root /var/www/html;
}
}
-rw-rw-rw- 501:20 /etc/nginx/sites-available/custom-site-raffi.conf
server {
listen 80;
server_name raffi.local;
root /home/raffi/public;
index index.html;
include ../conf.d/*.conf;
}
-rw-rw-rw- 501:20 /etc/nginx/sites-enabled/custom-site-raffi.conf -> ../sites-available/custom-site-raffi.conf
```