]> git.pld-linux.org Git - packages/etckeeper.git/blob - motd.sh
Up to 1.18.20
[packages/etckeeper.git] / motd.sh
1
2 git_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
7
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'
45
46 EOF
47 }
48
49 # run in subshell not to leak variables
50 git_config_check | cat
51 unset -f git_config_check
This page took 0.085418 seconds and 3 git commands to generate.