Add commands and scripts to user. (#7)

* If we're gonig to exit then we should be more sure about our messaging.

* Only have GIMP installed from Flatpak.

* Playbook is causing Ubuntu 20.04 to fail.

* Define gnome_install.failed since some Ansible versions are picky.

* Try again for mad non-Parrot versions of Ansible.

* Add debug.

* Still trying to make Ubuntu 20.04's Ansible happy.

* Fix typos.

* Ubuntu does not need to install Dash To Dock. Also ensure `make` is installed on other distros so that the project is compiled.

* Remove debug.

* Add remount and upgrade commands to RC files.

* Copy root scripts to also be for user.

* Call the new user script.

* Add new commands to rc_common so they're added to the rc files.

* Remove update file on Parrot OS.
This commit is contained in:
Hyperling 2021-08-14 10:03:55 -05:00 committed by GitHub
parent 3dec7e7d82
commit 37c5b122f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 168 additions and 8 deletions

View File

@ -8,7 +8,6 @@
ansible_python_interpreter: "/usr/bin/python3"
when: ansible_distribution == "Parrot OS"
- name: General | Facts | Package | apt
set_fact:
sshfs: sshfs
@ -16,14 +15,12 @@
opensshd: openssh-server
when: ansible_pkg_mgr == "apt"
- name: General | Facts | Package | pacman
set_fact:
sshfs: sshfs
locate: mlocate
opensshd: openssh
when: ansible_pkg_mgr == "pacman"
- name: General | Facts | Package | FreeBSD
set_fact:
@ -33,3 +30,58 @@
ansible_python_interpreter: "/usr/local/bin/python3.8"
when: ansible_system == "FreeBSD"
- name: General | Facts | Package | Update Commands | Helpers
set_fact:
update_accept_var: '$accept'
- name: General | Facts | Package | Update Commands | apt
set_fact:
update_package_manager: |
echo "*** Apt ***" &&
sudo apt update &&
sudo apt autoremove {{ update_accept_var }} &&
sudo apt dist-upgrade {{ update_accept_var }} &&
when: ansible_pkg_mgr == "apt"
- name: General | Facts | Package | Update Commands | pacman
set_fact:
update_package_manager: |
echo "*** Pacman ***" &&
sudo pacman -Syyu &&
when: ansible_pkg_mgr == "pacman"
- name: General | Facts | Package | Update Commands | pkg
set_fact:
update_package_manager: |
echo "*** Pkg ***" &&
sudo pkg update &&
sudo pkg upgrade &&
when: ansible_pkg_mgr == "pkg"
- name: General | Facts | Package | Update Commands | parrot-upgrade
set_fact:
update_package_manager: |
parrot_mirrors_suck=true
echo "*** Parrot ***"
while [[ $parrot_mirrors_suck ]]; do
unset parrot_mirrors_suck
sudo parrot-upgrade
if [[ $? != 0 ]]; then
parrot_mirrors_suck=true
sudo apt update --fix-missing
fi
done
when: ansible_distribution == "Parrot OS"
- name: General | Facts | Package | Update Commands | flatpak (Linux)
set_fact:
update_flatpak: |
echo "*** Flatpak ***" &&
flatpak update &&
when: ansible_system == "Linux"
- name: General | Facts | Package | Update Commands | flatpak (FreeBSD)
set_fact:
update_flatpak: echo "*** No Flatpak ***"
when: ansible_system == "FreeBSD"

View File

@ -28,6 +28,7 @@
- include: tasks/general/acct_mgmt/mounts.yml
- include: tasks/general/scripts/root.yml
- include: tasks/general/scripts/user.yml
- include: tasks/general/cron/ansible.yml
- include: tasks/general/cron/root.yml

View File

@ -113,8 +113,36 @@
fi
curl "https://wttr.in/${1//\ /+}"
}
PS1: |
export PS1='[\u@\h \w]\$ '
PS1: export PS1='[\u@\h \w]\$ '
remount: alias remount='sudo umount /mnt/*; sudo umount /mnt/*/*; sudo mount -a; echo -e "\nRemount completed!"; mount | grep /mnt'
update: |
function update() {
PROG=$FUNCNAME
usage="Usage: $PROG [-y]
$PROG is used to run all the system's package manager commands
in one swoop. Flow stops if any command returns a failure code.
The hope is to run something as easy as 'pacman -Syyu'.
-y : Assume yes to any prompts."
unset OPTIND
while getopts ":hy" opt; do
case $opt in
h) echo -e "$usage"
return 0 ;;
y) accept="-y" ;;
*) echo "ERROR: -$OPTARG is not a recognized option."
echo -e "$usage"
return 1 ;;
esac
done
{{ update_package_manager }}
{{ update_flatpak }}
return 0
echo "$PROG experienced a problem and has aborted."
return 1
}
- name: General | Account Management | Users | Files | Common Variable
set_fact:
@ -127,6 +155,8 @@
{{ alias_clean_trash }}
{{ function_wttr }}
{{ PS1 }}
{{ remount }}
{{ update }}
- name: General | Account Management | Users | Files | .bashrc
blockinfile:

View File

@ -0,0 +1,70 @@
---
# Create file to easily push git changes and call SCM.
- name: General | Scripts | User | scm.sh
blockinfile:
path: "{{ user_ling.home }}/bin/scm.sh"
block: |
# 20210211 - Make life easier!
push.sh
time curl https://scm.hyperling.com | sudo bash
marker: '{mark}'
marker_begin: "#!{{ bash_exec.stdout }}"
marker_end: "exit 0"
state: present
create: yes
- name: General | Scripts | User | scm.sh Permissions
file:
path: "{{ user_ling.home }}/bin/scm.sh"
mode: '0755'
- name: General | Scripts | User | push.sh
blockinfile:
path: "{{ user_ling.home }}/bin/push.sh"
block: |
# 20210215 - Make life even easier!
ssh ling@leet "cd Code/Ansible/ansible-pull; git push"
marker: '{mark}'
marker_begin: "#!{{ bash_exec.stdout }}"
marker_end: "exit 0"
state: present
create: yes
- name: General | Scripts | User | push.sh Permissions
file:
path: "{{ user_ling.home }}/bin/push.sh"
mode: '0755'
- name: General | Scripts | User | scm-dev.sh
blockinfile:
path: "{{ user_ling.home }}/bin/scm-dev.sh"
block: |
# 20210713 - Make life easier for development!
## Variables ##
# Use a specific branch if it was asked for.
branch="dev"
if [[ $1 != "" ]]; then
branch="$1"
fi
## Main ##
push.sh
time sudo {{ ansible_pull_exec.stdout }} -U https://github.com/Hyperling/ansible.git --checkout $branch
marker: '{mark}'
marker_begin: "#!{{ bash_exec.stdout }}"
marker_end: "exit 0"
state: present
create: yes
- name: General | Scripts | User | scm-dev.sh Permissions
file:
path: "{{ user_ling.home }}/bin/scm-dev.sh"
mode: '0755'

View File

@ -1,7 +1,7 @@
---
# Cross-platform package management.
- name: General | Software | Packages | Fix Parrot OS
- name: General | Software | Packages | Fix Parrot OS (zypper)
# They have zypper higher in the path, but it's really apt renamed.
# Probably for "security", but package module does not use the ansible_pkg_mgr variable
# so resetting the value to apt doesn't work. Just going to move it.
@ -10,15 +10,22 @@
ignore_errors: yes
when: ansible_distribution == "Parrot OS"
- name: General | Software | Packages | Fixed Parrot OS, Exit Incoming
- name: General | Software | Packages | Fix Parrot OS (zypper), Exit Incoming
debug:
msg: "A silly zypper file was renamed successfully. Please try running Ansible again."
when: ansible_distribution == "Parrot OS" and parrotos_zypper_removed is defined and not parrotos_zypper_removed.failed
- name: General | Software | Packages | Fixed Parrot OS, Exiting
- name: General | Software | Packages | Fix Parrot OS (zypper), Exiting
shell: exit 1
when: ansible_distribution == "Parrot OS" and parrotos_zypper_removed is defined and not parrotos_zypper_removed.failed
# More Parrot OS junk. They have a command called update in /usr/bin. Doesn't have sudo or anything in it either.
# Hide it in preference for .bashrc update function.
- name: General | Software | Packages | Fix Parrot OS 2 (update)
shell: "mv `which update` `which update`.zz.`date +%Y%m%d`"
ignore_errors: yes
when: ansible_distribution == "Parrot OS"
- name: General | Software | Packages | Cache Refresh (Apt and Pacman)
package: