]> git.pld-linux.org Git - packages/etckeeper.git/blame - motd.sh
Up to 1.18.20
[packages/etckeeper.git] / motd.sh
CommitLineData
a0b73458 1
c9313d99
ER
2git_config_check() {
3 # skip if env vars are set
4 if [ -n "$GIT_AUTHOR_NAME" -a -n "$GIT_AUTHOR_EMAIL" ]; then
5 return
6 fi
a0b73458 7
c9313d99
ER
8 # check if configured in ~/.gitconfig
9 email=$(git config --global --get user.email)
10 username=$(git config --global --get user.name)
11
12 # it's important for each user have their own ~/.gitconfig
13 if [ "$HOME" = "/root" ]; then
14 cat >&2 <<-'EOF'
15
16 IMPORTANT: Use 'sudo -s' to become root, so that the $HOME belongs to you not /root
17
18 EOF
19 fi
20
21 if [ -n "$email" -a -n "$username" ]; then
22 return
23 fi
24
25 user=${SUDO_USER:-$(id -un)}
26 gecos=$(getent passwd $user | cut -d: -f5)
27 email=$user@pld-linux.org
28
29 cat >&2 <<-EOF
30
31 Please commit your changes if you modify any files in /etc to git!
32 But before that please setup env vars to identify your commits in your ~/.bash_profile:
33
34 export GIT_AUTHOR_NAME='$gecos'
35 export GIT_AUTHOR_EMAIL='$email'
36
37 export GIT_COMMITTER_NAME=\${GIT_COMMITTER_NAME:-\$GIT_AUTHOR_NAME}
38 export GIT_COMMITTER_EMAIL=\${GIT_COMMITTER_EMAIL:-\$GIT_AUTHOR_EMAIL}
39
40 NOTE: GIT_* vars are imported with sshd so you could setup them where you connect from.
41
42 You may also use git config, but then you must learn to use 'sudo -s' to become root:
43 git config --global user.email '$email'
44 git config --global user.name '$gecos'
a0b73458 45
a0b73458 46EOF
c9313d99
ER
47}
48
49# run in subshell not to leak variables
50git_config_check | cat
51unset -f git_config_check
This page took 0.098723 seconds and 4 git commands to generate.