Option to run the installer script once.

master
Andrea Dell'Amico 4 months ago
parent f0e747a1c8
commit 3a5ad8eb66
Signed by: andrea.dellamico
GPG Key ID: 147ABE6CEB9E20FF

@ -44,6 +44,8 @@ r_packages_git_base_dir: /srv/r_updater
r_packages_files_prefix: ''
r_packages_updater_also_upgrades_installed_packages: true
r_packages_updater_for_github_only: true
# Set this to true if you want to run the installer once, and then never after the first execution
r_packages_updater_run_once: false
# They need to be flat text files
# 1 package per line
#r_debian_packages_list_url

@ -1,46 +1,58 @@
---
- name: Manage the subversion repository
- name: r-packages-updater | Manage the subversion repository
when:
- r_cran_install_from_sources
- r_packages_updater
- r_package_updater_via_subversion
tags: ['r_software', 'r_pkg', 'r_plugins', 'r_plugins_github', 'r_cran_pkgs', 'r_github_pkgs', 'r_packages_updater']
block:
- name: Create the R packages updater SVN base directory
file:
- name: r-packages-updater | Create the R packages updater SVN base directory
ansible.builtin.file:
dest: '{{ r_packages_svn_base_dir }}'
state: directory
owner: root
group: root
mode: "0755"
- name: r-packages-updater | Manage the git repository of the packages lists
when:
- r_cran_install_from_sources
- r_packages_updater
- r_package_updater_via_subversion
tags: [ 'r_software', 'r_pkg', 'r_plugins', 'r_plugins_github', 'r_cran_pkgs', 'r_github_pkgs', 'r_packages_updater' ]
- name: Manage the git repository of the packages lists
- r_package_updater_via_git
tags: ['r_software', 'r_pkg', 'r_plugins', 'r_plugins_github', 'r_cran_pkgs', 'r_github_pkgs', 'r_packages_updater']
block:
- name: Remove the R packages updater SVN base directory
file:
- name: r-packages-updater | Remove the R packages updater SVN base directory
ansible.builtin.file:
dest: '{{ r_packages_svn_base_dir }}/RPackagesManagement'
state: absent
- name: Create the R packages updater git base directory
file:
- name: r-packages-updater | Create the R packages updater git base directory
ansible.builtin.file:
dest: '{{ r_packages_git_base_dir }}'
state: directory
owner: root
group: root
mode: "0755"
when:
- r_cran_install_from_sources
- r_packages_updater
- r_package_updater_via_git
tags: [ 'r_software', 'r_pkg', 'r_plugins', 'r_plugins_github', 'r_cran_pkgs', 'r_github_pkgs', 'r_packages_updater' ]
- block:
- name: Install the R packages updater script
template:
- name: r-packages-updater | Scripts that install/update R packages
tags: ['r_software', 'r_pkg', 'r_plugins', 'r_plugins_github', 'r_cran_pkgs', 'r_github_pkgs', 'r_packages_updater']
block:
- name: r-packages-updater | Install the R packages updater script
ansible.builtin.template:
src: 'update_r_packages.sh.j2'
dest: '/usr/local/bin/update_r_packages'
owner: root
group: root
mode: '0755'
- name: Cron job that installs new R packages, if any
cron:
- name: r-packages-updater | Cron jobs that install/update R packages
when:
- r_cran_install_from_sources
- r_packages_updater
tags: ['r_software', 'r_pkg', 'r_plugins', 'r_plugins_github', 'r_cran_pkgs', 'r_github_pkgs', 'r_packages_updater']
block:
- name: r-packages-updater | Cron job that installs new R packages, if any
ansible.builtin.cron:
name: "install new R packages"
user: root
cron_file: install-r-packages
@ -49,8 +61,8 @@
job: "/usr/local/bin/update_r_packages install >/var/log/install_r_packages 2>&1"
state: present
- name: Cron job that upgrades existing R packages and installs new ones, if any
cron:
- name: r-packages-updater | Cron job that upgrades existing R packages and installs new ones, if any
ansible.builtin.cron:
name: "Upgrade installed R packages"
user: root
cron_file: upgrade-r-packages
@ -60,30 +72,30 @@
state: present
when: r_packages_updater_also_upgrades_installed_packages
when:
- r_cran_install_from_sources
- r_packages_updater
tags: [ 'r_software', 'r_pkg', 'r_plugins', 'r_plugins_github', 'r_cran_pkgs', 'r_github_pkgs', 'r_packages_updater' ]
- block:
- name: Remove the R packages updater script
file: dest=/usr/local/bin/update_r_packages state=absent
- name: Remove the R packages updater SVN base directory
file: dest={{ r_packages_svn_base_dir }} state=absent
- name: Remove the cron job that installs new R packages
file: dest=/etc/cron.d/install-r-packages state=absent
- name: Remove the cron job that upgrades existing R packages and installs new ones
file: dest=/etc/cron.d/upgrade-r-packages state=absent
- name: r-packages-updater | Remove the update scripts
when: not r_packages_updater
tags: [ 'r_software', 'r_pkg', 'r_plugins', 'r_plugins_github', 'r_cran_pkgs', 'r_github_pkgs', 'r_packages_updater' ]
tags: ['r_software', 'r_pkg', 'r_plugins', 'r_plugins_github', 'r_cran_pkgs', 'r_github_pkgs', 'r_packages_updater']
block:
- name: r-packages-updater | Remove the R packages updater SVN base directory
ansible.builtin.file:
dest: "{{ r_packages_svn_base_dir }}"
state: absent
- block:
- name: Disable the cron job that upgrades already installed R packages
file: dest=/etc/cron.d/upgrade-r-packages state=absent
- name: r-packages-updater | Remove the cron job that installs new R packages
ansible.builtin.file:
dest: /etc/cron.d/install-r-packages
state: absent
- name: r-packages-updater | Remove the cron job that upgrades existing R packages and installs new ones
ansible.builtin.file:
dest: /etc/cron.d/upgrade-r-packages
state: absent
- name: r-packages-updater | Disable the cron job that updates the R packages
when: not r_packages_updater_also_upgrades_installed_packages
tags: [ 'r_software', 'r_pkg', 'r_plugins', 'r_plugins_github', 'r_cran_pkgs', 'r_github_pkgs', 'r_packages_updater' ]
tags: ['r_software', 'r_pkg', 'r_plugins', 'r_plugins_github', 'r_cran_pkgs', 'r_github_pkgs', 'r_packages_updater']
block:
- name: r-packages-updater | Disable the cron job that upgrades already installed R packages
ansible.builtin.file:
dest: /etc/cron.d/upgrade-r-packages
state: absent

@ -42,6 +42,11 @@ UPDATER_DEFAULT_BEHAVIOUR="github_only"
{% else %}
UPDATER_DEFAULT_BEHAVIOUR="everything"
{% endif %}
{% if r_packages_updater_run_once %}
INSTALLER_BEHAVIOUR="once"
{% else %}
INSTALLER_BEHAVIOUR="always"
{% endif %}
# - debian packages list format:
# one package per line
DEB_PKGS_SKIP=0
@ -317,6 +322,14 @@ function r_github_pkgs() {
usage
get_args
init_env
if [ "$INSTALLER_BEHAVIOUR" == "once" ] ; then
if [ -d $R_PKGS_BASE_DIR/$R_PKGS_DIR ] ; then
logger "update_r_packages: The script run once already. Doing nothing."
cleanup
exit 0
fi
fi
if [ $R_PKGS_FROM_GIT == 'True' ] ; then
get_data_files_from_git
if [ $GIT_UPDATE_STATUS -ne 1 -a "$ACTION" == "install" ] ; then

Loading…
Cancel
Save