diff options
author | Ismaël Bouya <ismael.bouya@fretlink.com> | 2018-11-13 01:01:36 +0100 |
---|---|---|
committer | Ismaël Bouya <ismael.bouya@fretlink.com> | 2018-11-13 01:01:36 +0100 |
commit | a19180dfda49b96ff27911a71255ea3a504c4bb1 (patch) | |
tree | d33419cdf0534f7aaf259a4d85e5c707ba2016ee | |
parent | d0a835a44b3fd25267c3c8c6d3ed12e1e628816b (diff) | |
download | Ansible-a19180dfda49b96ff27911a71255ea3a504c4bb1.tar.gz Ansible-a19180dfda49b96ff27911a71255ea3a504c4bb1.tar.zst Ansible-a19180dfda49b96ff27911a71255ea3a504c4bb1.zip |
Move bashrc temporary file to state dir
-rw-r--r-- | roles/init/tasks/main.yml | 27 | ||||
-rw-r--r-- | roles/shell/bash/templates/bash_profile.j2 | 2 | ||||
-rw-r--r-- | roles/shell/bash/templates/bashrc.j2 | 4 |
3 files changed, 18 insertions, 15 deletions
diff --git a/roles/init/tasks/main.yml b/roles/init/tasks/main.yml index ce56ec4..a52f3cd 100644 --- a/roles/init/tasks/main.yml +++ b/roles/init/tasks/main.yml | |||
@@ -1,4 +1,16 @@ | |||
1 | --- | 1 | --- |
2 | - name: Create XDG dirs | ||
3 | file: | ||
4 | path: "{{ item }}" | ||
5 | state: directory | ||
6 | loop: | ||
7 | - "$XDG_CONFIG_HOME" | ||
8 | - "$XDG_STATE_HOME" | ||
9 | - "$XDG_STATE_HOME/bash" | ||
10 | - "$XDG_DATA_HOME" | ||
11 | - "$XDG_CACHE_HOME" | ||
12 | - "$HOME/Desktop" | ||
13 | - "$HOME/Downloads" | ||
2 | - name: Get gnupg runtime folder name | 14 | - name: Get gnupg runtime folder name |
3 | shell: 'GNUPGHOME=$XDG_CONFIG_HOME/gnupg gpgconf --list-dirs socketdir | sed -e "s@$XDG_RUNTIME_DIR/gnupg/@@"' | 15 | shell: 'GNUPGHOME=$XDG_CONFIG_HOME/gnupg gpgconf --list-dirs socketdir | sed -e "s@$XDG_RUNTIME_DIR/gnupg/@@"' |
4 | changed_when: false | 16 | changed_when: false |
@@ -12,7 +24,7 @@ | |||
12 | - name: Remove old lines in bashrc_temp | 24 | - name: Remove old lines in bashrc_temp |
13 | lineinfile: | 25 | lineinfile: |
14 | line: "{{ ('unset ' ~ item | regex_replace('=.*')) if item != '' and item.0 != '#' else '' }}" | 26 | line: "{{ ('unset ' ~ item | regex_replace('=.*')) if item != '' and item.0 != '#' else '' }}" |
15 | dest: $HOME/.bashrc_temp | 27 | dest: $XDG_STATE_HOME/bash/bashrc_temp |
16 | insertafter: EOF | 28 | insertafter: EOF |
17 | create: true | 29 | create: true |
18 | state: present | 30 | state: present |
@@ -21,7 +33,7 @@ | |||
21 | - name: Add new lines in bashrc_temp | 33 | - name: Add new lines in bashrc_temp |
22 | lineinfile: | 34 | lineinfile: |
23 | line: "{{ ('export ' ~ item) if item != '' and item.0 != '#' else '' }}" | 35 | line: "{{ ('export ' ~ item) if item != '' and item.0 != '#' else '' }}" |
24 | dest: $HOME/.bashrc_temp | 36 | dest: $XDG_STATE_HOME/bash/bashrc_temp |
25 | insertafter: EOF | 37 | insertafter: EOF |
26 | create: true | 38 | create: true |
27 | state: present | 39 | state: present |
@@ -31,14 +43,3 @@ | |||
31 | when: pam_environment.changed | 43 | when: pam_environment.changed |
32 | debug: | 44 | debug: |
33 | msg: "\u26A0\uFE0F \u26A0\uFE0F You need to log out and back in to update your environment \u26A0\uFE0F \u26A0\uFE0F" | 45 | msg: "\u26A0\uFE0F \u26A0\uFE0F You need to log out and back in to update your environment \u26A0\uFE0F \u26A0\uFE0F" |
34 | - name: Create XDG dirs | ||
35 | file: | ||
36 | path: "{{ item }}" | ||
37 | state: directory | ||
38 | loop: | ||
39 | - "$XDG_CONFIG_HOME" | ||
40 | - "$XDG_STATE_HOME" | ||
41 | - "$XDG_DATA_HOME" | ||
42 | - "$XDG_CACHE_HOME" | ||
43 | - "$HOME/Desktop" | ||
44 | - "$HOME/Downloads" | ||
diff --git a/roles/shell/bash/templates/bash_profile.j2 b/roles/shell/bash/templates/bash_profile.j2 index 9b9e86c..8ffd818 100644 --- a/roles/shell/bash/templates/bash_profile.j2 +++ b/roles/shell/bash/templates/bash_profile.j2 | |||
@@ -4,7 +4,7 @@ | |||
4 | {% if "graphical_vt" in features.get(profile, []) %} | 4 | {% if "graphical_vt" in features.get(profile, []) %} |
5 | 5 | ||
6 | if [[ ! $DISPLAY && $XDG_VTNR -eq 1 ]]; then | 6 | if [[ ! $DISPLAY && $XDG_VTNR -eq 1 ]]; then |
7 | [[ -f "$HOME/.bashrc_temp" ]] && rm -f $HOME/.bashrc_temp | 7 | [[ -f "$XDG_STATE_HOME/bash/bashrc_temp" ]] && rm -f $XDG_STATE_HOME/bash/bashrc_temp |
8 | exec startx $XDG_CONFIG_HOME/xinitrc > $XDG_STATE_HOME/xsession_errors 2>&1 | 8 | exec startx $XDG_CONFIG_HOME/xinitrc > $XDG_STATE_HOME/xsession_errors 2>&1 |
9 | fi | 9 | fi |
10 | {% endif %} | 10 | {% endif %} |
diff --git a/roles/shell/bash/templates/bashrc.j2 b/roles/shell/bash/templates/bashrc.j2 index fff19f7..91334b7 100644 --- a/roles/shell/bash/templates/bashrc.j2 +++ b/roles/shell/bash/templates/bashrc.j2 | |||
@@ -2,7 +2,7 @@ | |||
2 | # ~/.bashrc | 2 | # ~/.bashrc |
3 | # | 3 | # |
4 | 4 | ||
5 | [[ -f "$HOME/.bashrc_temp" ]] && . $HOME/.bashrc_temp | 5 | [[ -f "$XDG_STATE_HOME/bash/bashrc_temp" ]] && . $XDG_STATE_HOME/bash/bashrc_temp |
6 | 6 | ||
7 | if [ -n "$HOME/.local/bin" ]; then | 7 | if [ -n "$HOME/.local/bin" ]; then |
8 | PATH="$HOME/.local/bin:$PATH" | 8 | PATH="$HOME/.local/bin:$PATH" |
@@ -137,6 +137,8 @@ PS1='\[\033[01;31m\]$(error_code)\[\033[00;00m\]$(running_jobs)\[\033[01;32m\]$( | |||
137 | PS1='\[\033[01;31m\]$(error_code)\[\033[00;00m\]$(running_jobs)\[$(git_prompt_color)\]$(git_prompt)\[\033[00;32m\]\u@\h\[\033[94m\] \w \$\[\033[00m\] ' | 137 | PS1='\[\033[01;31m\]$(error_code)\[\033[00;00m\]$(running_jobs)\[$(git_prompt_color)\]$(git_prompt)\[\033[00;32m\]\u@\h\[\033[94m\] \w \$\[\033[00m\] ' |
138 | {% endif %} | 138 | {% endif %} |
139 | 139 | ||
140 | PROMPT_COMMAND="[[ -f "$XDG_STATE_HOME/bash/bashrc_temp" ]] && . $XDG_STATE_HOME/bash/bashrc_temp" | ||
141 | |||
140 | {% if "nodejs" in features.get(profile, []) %} | 142 | {% if "nodejs" in features.get(profile, []) %} |
141 | source /usr/share/nvm/init-nvm.sh | 143 | source /usr/share/nvm/init-nvm.sh |
142 | {% endif %} | 144 | {% endif %} |