Let's manage and deploy Debian systems with the help of a system-wide git repository.
sysgit provides some helpful commands and git hooks for this task. They are tested on Debian (real hosts and VM), Proxmox and Raspbian.
We provide some basic system variants:
- base - Just the init script and the git hooks (see repo)
- minimal - Base system with sysgit repository as submodule (see repo)
- full - Anything helpful (see repo)
First, init the system-wide git repository:
git init /
Merge our system variant into it. Choose a variant, see above.
cd /
git remote add upstream https://github.com/simonwalz/sysgit-variants.git
git fetch upstream
# git merge upstream/<VARIANT>
# i.e.
git merge upstream/minimal
And run the init script. This installs the git hooks and initialize the submodules:
/.sysgit/init.sh
(optional) Add your remote:
git remote add origin GIT_URL
git push -u origin master
First, init the system-wide git repository:
git init /
Add your remote:
git remote add origin GIT_URL
git fetch origin
git branch --track "master" "origin/master"
Use either:
git reset --mixed && git checkout-index -a
# or
git reset --hard && git checkout-index -a
to restore your files. --mixed
only write non-existing files. --hard
overwrites all files.
And run the init script:
/.sysgit/init.sh
The git merge command fails if we try to merge an other repository.
Thus use the commands in "Initialize from an empty repository" and use the following command insteed of the merge command:
# git rebase --onto upstream/<VARIANT> --root master
# i.e.
git rebase --onto upstream/minimal --root master
# force push:
git push -f
Or cherry-pick the commits you what.
The following tools are automatically installed in minimal and full variants via a submodule and linked into path (by /.sysgit/init.sh
). You can use these tools without the system variants; you only need to add all executables to the path.
See git documentation. Use git add FILE
, git commit -m "Message"
and git push
.
Show git status WITHOUT unchanged Debian system-files.
Usage: See git status.
This tool runs git sys-ignore --update
before showing the status.
Update the git exclude file (/.git/info/exclude
).
This is automatically executed before showing git sys-status
.
Configure which files shall be ignored.
git sys-ignore
git sys-ignore PATTERN
git sys-ignore 110 120 130
To remove a pattern, edit /etc/sysgit/ignore-config
Index all untracked files. If you change one of these files, it will
show up in git sys-status
.
The index is saved to /etc/sysgit/local-config.ignore-chk
Show differences of a file to version of the Debian package:
git sys-diff debian-system-file
Get commits from one (or multiple) foreign repository (of remote upstream
):
git sys-update [<VARIANT> [<VARIANT2> ...]]
Example
git sys-update minimal ansible
You can omit the variant parameters if you saved it in the past with
git sys-update --save <VARIANT> [<VARIANT2> ...]
Background: The command executes the following git commands:
cd /
git fetch upstream
git merge upstream/<VARIANT>
List all user installed packages (or write them to /etc/sysgit/apt-packages
)
In minimal system variant, this script is automatically called by a apt hook.
--list
- Show list of installed packages--save
- Save list to/etc/sysgit/apt-packages
--install
- Install Packages listed in/etc/sysgit/apt-packages