#!/bin/bash [ "$1" == "-h" ] && echo "install-runc.sh install|update|remove|restart|scripts|reinstall" && exit 1 SERVICE_NAME="" SCRIPTS_DEPLOY_PATH="" [ -r "env-runc" ] && . ./env-runc [ -r "common.sh" ] && . ./common.sh ARCH="$(uname -m | sed -e 's/x86_64/amd64/' -e 's/\(arm\)\(64\)\?.*/\1\2/' -e 's/aarch64$/arm64/')" RUNC_VERSION="${RUNC_VERSION:-1.1.15}" RUNC_URL="https://github.com/opencontainers/runc/releases/download/v${RUNC_VERSION}/runc.${ARCH}" CMD_TSK=${CMD_TSK:-${1:-install}} export LC_CTYPE=C.UTF-8 LANG=C.UTF-8 _update_binary() { [ -z "$RUNC_VERSION" ] && return 1 local curr_vers has_runc has_runc=$(type runc 2>/dev/null) [ -n "$has_runc" ] && curr_vers=$(runc --version 2>/dev/null | grep "^runc version" | awk '{print $3}') [ "$curr_vers" == "$RUNC_VERSION" ] && return 0 if ! curl -fsSL "$RUNC_URL" -o runc; then echo "error downloading runc"; return 1 fi chmod +x runc && sudo mv runc /usr/local/bin/runc [ -f "/usr/bin/runc" ] && sudo mv /usr/bin/runc /usr/bin/_runc return 0 } _config_runc() { for mod in overlay br_netfilter; do sudo grep -q "^${mod}" /etc/modules-load.d/runc.conf 2>/dev/null \ || echo "$mod" | sudo tee -a /etc/modules-load.d/runc.conf >/dev/null done } case "$CMD_TSK" in reinstall) sudo rm -f /usr/local/bin/runc ;& install) _update_binary || { echo "error runc install"; exit 1; } _config_runc ;; update) _common_update ;; scripts) _common_deploy_scripts ;; config) _config_runc ;; restart) _common_service_restart ;; remove) sudo rm -f /usr/local/bin/runc ;; delete) sudo rm -f /usr/local/bin/runc /usr/bin/_runc sudo rm -f /etc/modules-load.d/runc.conf ;; esac