From d13417911c8b0965771564b08b4a63f60a73c2a4 Mon Sep 17 00:00:00 2001 From: LinuxSquare Date: Thu, 27 Jun 2024 22:33:38 +0200 Subject: [PATCH] Add shell playbook --- system/files/shell_profile.j2 | 34 ++++++++++++++++++++++++++++++++++ system/init.ansible.yml | 2 +- system/shell.ansible.yml | 19 +++++++++++++++++++ 3 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 system/files/shell_profile.j2 diff --git a/system/files/shell_profile.j2 b/system/files/shell_profile.j2 new file mode 100644 index 0000000..03d46ea --- /dev/null +++ b/system/files/shell_profile.j2 @@ -0,0 +1,34 @@ +export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:{{ CUSTOM_BIN }}" + +export PAGER=less +export EDITOR=vim +umask 022 + +# use nicer PS1 for bash and busybox ash +if [ -n "$BASH_VERSION" -o "$BB_ASH_VERSION" ]; then + PS1='[%n@%m %~]%# ' +# use nicer PS1 for zsh +elif [ -n "$ZSH_VERSION" ]; then + PS1='[%n@%m %~]%# ' +# set up fallback default PS1 +else + : "${HOSTNAME:=$(hostname)}" + PS1='${HOSTNAME%%.*}:$PWD' + [ "$(id -u)" -eq 0 ] && PS1="${PS1}# " || PS1="${PS1}\$ " +fi + +if [ -n "$BASH_VERSION" ] && [ "$BASH" != "/bin/sh" ]; then + # if we're bash (and not /bin/sh bash), also source the bashrc + # by default, bash sources the bashrc for non-login, + # and only /etc/profile on login (-l). so, make it do both on login. + # this ensures that login-shell bash (e.g. -bash or bash -l) still sources the + # system bashrc, which e.g. loads bash-completion + . /etc/bash/bashrc +fi + +for script in /etc/profile.d/*.sh ; do + if [ -r "$script" ] ; then + . "$script" + fi +done +unset script diff --git a/system/init.ansible.yml b/system/init.ansible.yml index 7c6dd66..a26556f 100644 --- a/system/init.ansible.yml +++ b/system/init.ansible.yml @@ -2,6 +2,6 @@ - import_playbook: bootloader.ansible.yml - import_playbook: disks.ansible.yml - import_playbook: user.ansible.yml -# - import_playbook: shell.ansible.yml +- import_playbook: shell.ansible.yml # - import_playbook: ansible.ansible.yml diff --git a/system/shell.ansible.yml b/system/shell.ansible.yml index e69de29..44a2e16 100644 --- a/system/shell.ansible.yml +++ b/system/shell.ansible.yml @@ -0,0 +1,19 @@ +- hosts: localhost + vars_files: + - ../map.yml + tasks: + - name: Install shell base-packages + package: + name: + - zsh + - alpine-zsh-config + - bash + - name: Populate shell profile + template: + src: files/shell_profile.j2 + dest: /etc/profile + owner: root + group: root + mode: '0644' + vars: + CUSTOM_BIN: "{{ bin_dir }}"