4c5794f4fc918219cc18131e9e5e22f3f0f14f0e
[distro-setup] / filesystem / etc / profile.d / environment.sh
1 if [ -f $HOME/path_add-function ]; then
2 . $HOME/path_add-function
3 path_add /usr/sbin /usr/local/sbin /sbin
4 path_add /a/exe /a/opt/bin $HOME/.cabal/bin
5
6 if [ -r /etc/alternatives/java_sdk ]; then
7 export JAVA_HOME=/etc/alternatives/java_sdk
8 path_add /etc/alternatives/java_sdk
9 fi
10 fi
11
12 export EDITOR="emacsclient"
13 # this makes emacsclient file/-c start a server instance if none is running,
14 # instead of some alternate editor logic
15 export ALTERNATE_EDITOR=""
16
17
18 # makes subsequent syscalls to localtime use cached timezone,
19 # so basically restart the comp if you change time zones,
20 # and avoid a few syscalls, which makes a tiny tiny perf difference.
21 # I also set this in
22 # /a/c/filesystem/etc/systemd/system.conf.d/tz.conf
23 # https://blog.packagecloud.io/eng/2017/02/21/set-environment-variable-save-thousands-of-system-calls/
24 export TZ=:/etc/localtime
25
26 # ubuntu starts gpg agent automatically with /etc/X11/Xsession.d/90gpg-agent.
27 # fedora doesn't, which left me to figure this out, and google was no help.
28 # fedora documentation is often quite bad :(
29 # This is mostly copied from that file.
30 # Main difference is that we eval the result of starting gpg-agent,
31 # while that file executes it through xsession specific var.
32 # Also make sourcing the pidfile make more sense.
33 # End result should be the same afaik.
34 # for gpg-agent to work when calling gpg from the command line,
35 # we need an environment variable that is setup via the eval.
36 # which is why we do this upon login, so it can propogate
37 # It is also written to the file $HOME/.gnupg/gpg-agent-info-$(hostname)
38 # I'm not aware if that is ever used, but just fyi.
39 # I also added the bit about xmessaging the stderr,
40 # because I'd like to know if the command fails
41 if [ -f /etc/fedora-release ]; then
42 : ${GNUPGHOME=$HOME/.gnupg}
43
44 GPGAGENT=/usr/bin/gpg-agent
45 PID_FILE="$GNUPGHOME/gpg-agent-info-$(hostname)"
46
47 if ! $GPGAGENT 2>/dev/null; then
48 temp="$(mktemp)"
49 eval "$($GPGAGENT --homedir /p/do-not-delete --daemon --sh --write-env-file=$PID_FILE 2>$temp)"
50 temperr="$(<"$temp")"
51 [ -n "$temperr" ] && xmessage "gpg-agent stderr: $temperr"
52 elif [ -r "$PID_FILE" ]; then
53 . "$PID_FILE"
54 export GPG_AGENT_INFO
55 fi
56 fi
57
58 # background:
59 # ubuntu has 002 for non-system users, debian has 022. 002 makes groups
60 # be rw instead of r.
61 #
62 # ubuntu is more user friendly when using multiple users. However,
63 # it also makes it so if you create a file as a regular user then move
64 # it to become a system file, it's got slightly wrong permissions, and
65 # sometimes thing break. Also, copying files between ubuntu and debian
66 # makes things inconsistent. So stick with 022 umask always.
67 #
68 # One security concern is where some unixes put every user in a same
69 # group, so if you copy files there with exact perms, that is probably
70 # not what you want. I don't use a system like that, so I don't
71 # care.
72 umask 022
73 # this is how we could test for non-system user
74
75 #if test "$(id -u)" -ge 1000; then : fi