Skip to content

Commit 3786668

Browse files
committed
README.md written
1 parent 0de35eb commit 3786668

File tree

8 files changed

+254
-147
lines changed

8 files changed

+254
-147
lines changed

README.md

Lines changed: 182 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
1+
# sysgit - git based debian provisioning toolkit
2+
3+
Let's manage and deploy debian systems with the help of a system-wide
4+
git repository.
5+
6+
sysgit provides some helpfull commands and git hooks for this task.
7+
8+
## Initialize
9+
10+
### System variants:
11+
12+
We provide some basic system variants:
13+
14+
* **base** - Just the init script and the git hooks
15+
* **minimal** - Base system with sysgit repository as submodule
16+
* **full** - Anything helpfull
17+
18+
### Initialize from an empty repository
19+
20+
First, init the system-wide git repo:
21+
```
22+
git init /
23+
```
24+
25+
Merge our system variant into it. Choose a variant, see above.
26+
```
27+
cd /
28+
git remote add upstream https://github.com/simonwalz/sysgit-variants.git
29+
git fetch upstream
30+
# git merge upstream/<VARIANT>
31+
# i.e.
32+
git merge upstream/minimal
33+
```
34+
35+
And run the init script. This installs the git hooks and initialize the submodules:
36+
```sh
37+
/.sysgit/init.sh
38+
```
39+
40+
41+
(optional) Add your remote:
42+
```
43+
git remote add origin GIT_URL
44+
git checkout -b master --track origin/master
45+
git push
46+
```
47+
48+
49+
### Initialize from existing repository
50+
51+
First, init the system-wide git repo:
52+
```sh
53+
git init .
54+
```
55+
56+
Add your remote:
57+
```sh
58+
git remote add origin GIT_URL
59+
git checkout -b master --track origin/master
60+
```
61+
62+
Use either:
63+
```sh
64+
git reset --mixed origin/master
65+
# or
66+
git reset --hard origin/master
67+
```
68+
to restore your files. `--mixed` only write non-existing files. `--hard` overwrites all files.
69+
70+
71+
And run the init script:
72+
```sh
73+
/.sysgit/init.sh
74+
```
75+
76+
### Port an other system-wide git not managed via sysgit:
77+
78+
The git merge command fails if we try to merge an other repo.
79+
80+
Thus use the commands in "Initialize from an empty repository" and
81+
use the following commands to rebase your existing commits:
82+
83+
```sh
84+
git remote add old GIT_URL
85+
git fetch old
86+
# git rebase --onto upstream/<VARIANT> --root old/master
87+
# i.e.
88+
git rebase --onto upstream/minimal --root old/master
89+
90+
# force push:
91+
git push -f
92+
```
93+
94+
Or cherry-pick the commits you what.
95+
96+
## Working
97+
98+
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.
99+
100+
### Use git
101+
102+
See [git documentation](https://git-scm.com/docs/). Use `git add FILE`, `git commit -m "Message"` and `git push`.
103+
104+
### Command: `git sys-status`
105+
106+
Show git status WITHOUT unchanged debian system-files.
107+
108+
Usage: See [git status](https://git-scm.com/docs/git-status).
109+
110+
This tool runs `git sys-ignore --update` before showing the status.
111+
112+
### Command: `git sys-ignore-gen` (internal use)
113+
114+
Update the git exclude file (`/.git/info/exclude`).
115+
This is automatically executed before showing `git sys-status`.
116+
117+
### Command: `git sys-ignore`
118+
119+
Configure which files shall be ignored.
120+
121+
#### Usage: List pattern:
122+
123+
```sh
124+
git sys-ignore
125+
```
126+
127+
#### Usage: Add pattern:
128+
```sh
129+
git sys-ignore PATTERN
130+
```
131+
132+
#### Example:
133+
```sh
134+
git sys-ignore 110 120 130
135+
```
136+
137+
To remove a pattern, edit /etc/sysgit/ignore-config
138+
139+
140+
### Command: `git sys-ignore-untracked`
141+
142+
Index all untracked files. If you change one of these files, it will
143+
show up in `git sys-status`.
144+
145+
The index is saved to `/etc/sysgit/local-config.ignore-chk`
146+
147+
### Command: `git sys-diff`
148+
149+
Show differences of a file to version of the debian package:
150+
151+
#### Usage:
152+
```sh
153+
git sys-diff debian-system-file
154+
```
155+
156+
157+
### Command: `git sys-update`: update variant
158+
159+
Get commits from one (or multiple) foreign repository (of remote `upstream`):
160+
161+
```sh
162+
git sys-update [<VARIANT> [<VARIANT2> ...]]
163+
```
164+
165+
Example
166+
```sh
167+
git sys-update minimal ansible
168+
```
169+
170+
You can obmit the variant parameters if you saved it in the past with
171+
```sh
172+
git sys-update --save <VARIANT> [<VARIANT2> ...]
173+
```
174+
175+
176+
Background: The command executes the following git commands:
177+
```sh
178+
cd /
179+
git fetch upstream
180+
git merge upstream/<VARIANT>
181+
```
182+

git-sys-apt-history

Lines changed: 0 additions & 30 deletions
This file was deleted.

git-sys-cmd

Lines changed: 0 additions & 77 deletions
This file was deleted.

git-sys-ignore

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
3+
SCRIPTPATH="$(readlink -f 2>/dev/null || perl -MCwd -e 'print Cwd::abs_path shift' $0)"
4+
cd "$(dirname "${SCRIPTPATH}")"
5+
6+
if test "x$1" = "x" || test "x" = "x--list"
7+
then
8+
9+
cd extra.ignore.d
10+
11+
ls | sed -r "s/\..*$//"
12+
13+
exit 0
14+
fi
15+
16+
mkdir -p /etc/sysgit/
17+
for ignore
18+
do
19+
echo "extra.ignore.d/${ignore}" >>/etc/sysgit/ignore_config
20+
done
21+

debian-config-gitignore renamed to git-sys-ignore-gen

Lines changed: 48 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,7 @@
33
export LANG=C
44
export LC_ALL=C
55

6-
type -p debsums >/dev/null 2>&1
7-
if test "x$?" = "x1"
8-
then
9-
echo "Please install debsums" >&2
10-
echo "apt-get intall debsums" >&2
11-
exit 2
12-
fi
13-
14-
SCRIPT=$(readlink -f "$0")
15-
SCRIPTPATH=$(dirname "$SCRIPT")
16-
17-
IGNORE_PATTERN="ignore.d/"
18-
19-
if test -f ${SCRIPTPATH}/config.sh
20-
then
21-
source ${SCRIPTPATH}/config.sh
22-
fi
23-
24-
(
6+
get_files() {
257
cd /
268

279
md5sum -c /var/lib/ucf/hashfile | grep 'OK$' | sed -e 's/: *OK *$//'
@@ -49,7 +31,52 @@ fi
4931
/etc/php5/cli/conf.d \
5032
-type l
5133

52-
) 2>/dev/null | awk '!x[$0]++' >/.git/info/exclude
53-
# awk '!x[$0]++' == uniq without sorting
34+
}
35+
36+
get_files_uniq() {
37+
get_files 2>/dev/null | awk '!x[$0]++'
38+
# awk '!x[$0]++' == uniq without sorting
39+
}
40+
41+
42+
type -p debsums >/dev/null 2>&1
43+
if test "x$?" = "x1"
44+
then
45+
echo "Please install debsums" >&2
46+
echo "apt-get intall debsums" >&2
47+
exit 2
48+
fi
49+
50+
SCRIPT=$(readlink -f "$0")
51+
SCRIPTPATH=$(dirname "$SCRIPT")
52+
53+
IGNORE_PATTERN="ignore.d/
54+
/etc/sysgit/local-config"
55+
56+
if test -f ${SCRIPTPATH}/config.sh
57+
then
58+
source ${SCRIPTPATH}/config.sh
59+
fi
60+
61+
if test -f "/etc/sysgit/ignore-config"
62+
then
63+
config_ignore="$(cat "/etc/sysgit/ignore-config")"
64+
IGNORE_PATTERN="${IGNORE_PATTERN}
65+
${config_ignore}"
66+
fi
67+
68+
69+
if test "x$1" = "x--update"
70+
then
71+
get_files_uniq >/.git/info/exclude
72+
else
73+
get_files_uniq
74+
echo
75+
echo "Run"
76+
echo " git sys-ignore --update"
77+
echo "to update system-wide git exclude file."
78+
echo "This script is automatically executed when running"
79+
echo " git sys-status"
80+
fi
5481

5582
exit 0

0 commit comments

Comments
 (0)