Continuum Analytics: Documentation

# upgrade_400.sh

    #!/usr/bin/env bash

    # Loop through each user folder in /projects
    sudo find /projects -maxdepth 1 -type d -print | while read f; do
        ownr=`echo "${f}" | cut -d'/' -f 3`
        # Skip blank owners (happens for /projects by itself)
        if [ -z "$ownr" ]; then continue; fi
        # Fix project rc (this should match the functionality in functions.sh -> fix_project_rc)
        sudo find "${f}" -maxdepth 1 -type d -print | while read PROJECT_HOME; do
            project_name=`echo "${PROJECT_HOME}" | cut -d'/' -f 4`
            # Skip blank owners (happens for /projects/owner by itself)
            if [ -z "$project_name" ]; then continue; fi
            oldline='export CONDA_ENVS_PATH=$WAKARI_PROJECT_HOME/envs:$CONDA_ENVS_PATH'
            newline='export CONDA_ENVS_PATH=$WAKARI_PROJECT_HOME/envs:${CONDA_ENVS_PATH:-DEFAULTS}'
            sudo cp "${PROJECT_HOME}"/.projectrc "${PROJECT_HOME}"/.projectrc.new
            sudo sed "s+$oldline+$newline+" "${PROJECT_HOME}"/.projectrc.new | sudo tee "${PROJECT_HOME}"/.projectrc > /dev/null
        done
        # Change /projects/owner to be owned by wakari
        echo "Upgrading projects owned by ${ownr}. This could take several minutes..."
        sudo chown wakari:wakari "${f}"
        sudo chmod 711 "${f}"
        sudo setfacl -m u:"${ownr}":rwx "${f}"
        # Change ownership of any root-owned files to the project owner
        sudo find "${f}" -user root -exec chown "${ownr}":"${ownr}" {} \;
        # Give wakari ACL permissions for all projects
        sudo find "${f}" -type d '!' -user wakari -exec setfacl -m u:wakari:rwX,d:u:wakari:rwX '{}' ';'
        sudo find "${f}" -type f '!' -user wakari -exec setfacl -m u:wakari:rwX '{}' ';'
        # Force re-granting of permissions at next project startup
        sudo find "${f}" -maxdepth 3 -name .skip_perms -exec rm {} \;
    done

    # Fix ownership of pidfiles
    echo "Fixing pidfile ownership"
    sudo chown -R wakari:wakari /opt/wakari/wakari-compute/var/run/compute-launcher-apps/

    # Fix ownership of logfiles
    echo "Fixing logfile ownership"
    sudo chown -R wakari:wakari /opt/wakari/wakari-compute/var/log/wakari/compute-launcher-apps/

    echo "Done upgrading."