#!/bin/bash
# p5 - Plone helper
set -e
source "/home/zwelch/src/mcf/mcsh-release/install/share/mcsh/mcsh.sh"
lib_load 'net/tool/plone'
######
# Settings
p5_config_init() {
# the global site directory
script_setting_vars p5_plonedir
# per-site defaults
script_setting_vars p5_version p5_clients
}
p5_config_check() {
:
}
######
# Plone Site CLI
p5_site() { require_superuser; cmd_dispatch "$@"; }
p5_site_usage() {
cat <<USAGE
<cmd> ...
Plone Site Commands:
list Lists all known Plone sites
exists <name> Returns success if Plone site exists
path <name> [<path>] Prints base path of Plone site
Plone Site Creation:
add <name> <dir> Adds an existing Plone site
create <name> [<dir>] Installs Plone in dir (default:
$p5_plonedir/<name>)
config ... Plone site configuration commands
Plone Site Maintenance:
rename <old> <new> Renames the Plone site
remove <name> Remove the named Plone site
delete <name> Remove and delete the named Plone site
USAGE
}
p5_site_list() { plone_site_list "$@"; }
p5_site_exists() { plone_site_exists "$@"; }
p5_site_path() { plone_site_path "$@"; }
p5_site_add() { plone_site_add "$@"; }
p5_site_create() { plone_site_create "$1" "${2:-$p5_plonedir/$1}"; }
p5_site_rename() { plone_site_rename "$@"; }
p5_site_remove() { plone_site_remove "$@"; }
p5_site_delete() { plone_site_delete "$@"; }
######
# Plone site configuration commands
p5_site_config() { cmd_dispatch "$@"; }
p5_site_config_usage() {
cat <<USAGE
<cmd> ...
Plone Site Configuration Commands:
init <name> [<#cpus>] [<vers>] Creates Plone site configuration file
show <name> Displays Plone site configuration file
edit <name> Edits Plone site configuration file
USAGE
}
p5_site_config_init() {
min_args 1 "$@"
local name=$1
[ "$2" ] || info "$name: using default number of clients"
local clients=${2:-$p5_clients}
[ "$3" ] || info "$name: using default version"
local version=${3:-$p5_version}
plone_site_config_init "$name" "$version" "$clients"
app_echo "Plone site created with the following settings:"
plone_site_config_show "$name"
app_echo "Run '$script_name site config edit \"$name\"' to modify these settings."
}
p5_site_config_show() { plone_site_config_show "$@"; }
p5_site_config_edit() { plone_site_config_edit "$@"; }
######
# Plone Installler CLI
p5_installer() { require_superuser; cmd_dispatch "$@"; }
p5_installer_usage() {
cat <<USAGE
<cmd> ...
Plone Site Installer Commands:
fetch <name> Downloads Plone unified installer archive
extract <name> Extracts Plone unified installer archive
run <name> Installs Plone site using unified installer
Low-Level Plone Site Installer Commands:
exec <name> [...] Runs the unified installer with given args
USAGE
}
p5_installer_fetch() { plone_installer_download "$@"; }
p5_installer_extract() { plone_installer_extract "$@"; }
p5_installer_run() { plone_installer_run "$@"; }
p5_installer_exec() { plone_installer_exec "$@"; }
######
# Plone Buildout CLI
p5_buildout() { cmd_dispatch "$@"; }
p5_buildout_usage() {
cat <<USAGE
<cmd> ...
Plone Site Buildout Commands:
edit <name> Edits buildout configuration file
build <name> Runs buildout to (re)build installation
USAGE
}
p5_buildout_edit() { run_as_buildout "$1" "$EDITOR" buildout.cfg; }
p5_buildout_build() { run_as_buildout "$1" bin/buildout "$@"; }
######
# Plone Cluster CLI
p5_cluster() { require_superuser; cmd_dispatch "$@"; }
p5_cluster_usage() {
cat <<USAGE
<cmd> ...
Plone Cluster Commands:
start [<name>+] Starts Plone cluster(s)
stop [<name>+] Stops Plone cluster(s)
restart [<name>+] Restarts Plone cluster(s)
Plone Cluster Command Groups:
config ... Configuration commands
USAGE
}
p5_cluster_start() { for_each plone_cluster_start "$@"; }
p5_cluster_stop() { for_each plone_cluster_stop "$@"; }
p5_cluster_restart() { for_each plone_cluster_restart "$@"; }
p5_cluster_config() { cmd_dispatch "$@"; }
p5_cluster_config_usage() {
cat <<USAGE
<cmd> <name>
Plone Cluster Configuration Commands:
show <name> Show contents of supervisor configuration file
install <name> Install supervisor configuration file
remove <name> Remove supervisor configuration file
USAGE
}
p5_cluster_config_show() { plone_cluster_conf_show "$@"; }
p5_cluster_config_install() { plone_cluster_conf_install "$@"; }
p5_cluster_config_remove() { plone_cluster_conf_remove "$@"; }
######
# Plone cron support
p5_cron() { require_superuser; cmd_dispatch "$@"; }
p5_cron_usage() {
cat <<USAGE
<cmd> <name>
Plone Cron Commands:
run <name> Performs periodic tasks for Plone site
init <name> Installs crontab for Plone site
remove <name> Removes crontab for Plone site
USAGE
}
p5_cron_run() { plone_cron_run "$@"; }
p5_cron_init() { plone_cron_install "$@"; }
p5_cron_remove() { plone_cron_remove "$@"; }
######
# Plone Wizard
p5_wizard() { require_superuser; cmd_dispatch "$@"; }
p5_wizard_usage() {
cat <<USAGE
Plone Wizard Commands:
run <name> Runs the Plone site creation wizard
enable <name> Enables a Plone site
disable <name> Disables a Plone site
USAGE
}
p5_wizard_run() {
has_args 1 "$@"
local name=$1
info "$name: creating site..."
p5_site_create "$name"
p5_site_config_init "$name"
p5_installer_run "$name"
p5_wizard_enable "$name"
info "$name: ... site created!"
}
p5_wizard_enable() {
plone_cluster_conf_install "$name"
plone_cron_install "$name"
}
p5_wizard_disable() {
has_args 1 "$@"
local name=$1
plone_cron_remove "$name"
plone_cluster_stop "$name"
plone_cluster_conf_remove "$name"
}
######
# WebDAV CLI
p5_webdav() {
lib_load 'net/webdav'
webdav_dispatch "$@"
}
######
# Check
p5_check_live() {
local name="${script_name}-check"
p5_wizard "$name"
p5_disable "$name"
}
######
# Main
p5_desc() { echo "Plone helper"; }
p5_usage() {
cat <<USAGE
<cmd> ...
Plone Commands:
wizard ... Plone wizard commands
site ... Plone site commands
installer ... Plone installer commands
buildout ... Plone buildout commands
cluster ... Plone cluster commands
webdav ... Plone webdav commands
USAGE
}
p5_help() {
cat <<HELP
The $script_name tool automates management of multiple concurrent Plone
sites. Its major command groups cover the various phases of site
deployment, including configuration, initial installation, buildout, and
cluster runtime management.
HELP
}
app_run "$@"
Generated on Fri Jul 28 14:34:36 PDT 2017 by mcsh d14 v0.23.0.