Skip to content
Snippets Groups Projects
Commit 6a15414d authored by Chris Croome's avatar Chris Croome
Browse files

update-alternatives fsct script added

parent e2611591
No related branches found
No related tags found
1 merge request!1Merge Sury
Pipeline #20926 failed
......@@ -35,10 +35,19 @@
group: root
register: php_phpquery_facts
- name: Ansible PHP update-alternatives local facts script present
ansible.builtin.template:
src: php_alternatives.fact.j2
dest: /etc/ansible/facts.d/php_alternatives.fact
mode: 0700
owner: root
group: root
register: php_alternatives_facts
- name: Re-read Ansible local facts
ansible.builtin.setup:
filter: ansible_local
when: ( php_dpkg_arch_facts.changed ) or ( php_phpquery_facts.changed )
when: ( php_dpkg_arch_facts.changed ) or ( php_phpquery_facts.changed ) or ( php_alternatives_facts.changed )
- name: Print Ansible dpkg --architecture variables
debug:
......
#!/usr/bin/env bash
{{ ansible_managed }}
set -euo pipefail
jo $(
if [[ -L "/usr/bin/php" ]]
then
echo php=$(
declare -a alternatives=()
readarray -t alternatives < <(update-alternatives --query php | grep -e '^Alternative' | sed 's;Alternative: /usr/bin/php;;')
declare -a priorities=()
readarray -t priorities < <(update-alternatives --query php | grep -e '^Priority' | sed 's/Priority: //')
jo $(
for i in $(seq 0 $(("${#alternatives[@]}"-1)))
do
echo "${alternatives[${i}]}=${priorities[${i}]}"
done
)
)
fi
if [[ -L "/usr/bin/phar" ]]
then
echo phar=$(
declare -a alternatives=()
readarray -t alternatives < <(update-alternatives --query phar | grep -e '^Alternative' | sed 's;Alternative: /usr/bin/phar;;')
declare -a priorities=()
readarray -t priorities < <(update-alternatives --query phar | grep -e '^Priority' | sed 's/Priority: //')
jo $(
for i in $(seq 0 $(("${#alternatives[@]}"-1)))
do
echo "${alternatives[${i}]}=${priorities[${i}]}"
done
)
)
fi
if [[ -L "/usr/bin/phar.phar" ]]
then
echo phar.phar=$(
declare -a alternatives=()
readarray -t alternatives < <(update-alternatives --query phar.phar | grep -e '^Alternative' | sed 's;Alternative: /usr/bin/phar.phar;;')
declare -a priorities=()
readarray -t priorities < <(update-alternatives --query phar.phar | grep -e '^Priority' | sed 's/Priority: //')
jo $(
for i in $(seq 0 $(("${#alternatives[@]}"-1)))
do
echo "${alternatives[${i}]}=${priorities[${i}]}"
done
)
)
fi
if [[ -L "/run/php/php-fpm.sock" ]]
then
echo php-fpm.sock=$(
declare -a alternatives=()
readarray -t alternatives < <(update-alternatives --query php-fpm.sock | grep -e '^Alternative' | sed 's;Alternative: /run/php/php;;' | sed 's/-fpm.sock$//')
declare -a priorities=()
readarray -t priorities < <(update-alternatives --query php-fpm.sock | grep -e '^Priority' | sed 's/Priority: //')
jo $(
for i in $(seq 0 $(("${#alternatives[@]}"-1)))
do
echo "${alternatives[${i}]}=${priorities[${i}]}"
done
)
)
fi
)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment