Commit d7397f32 authored by Paul Cammish's avatar Paul Cammish
Browse files

Updated 'sympl' parser

parent 88a6565e
......@@ -2,7 +2,7 @@
#
# Sympl command line interface.
#
# Copyright 2019, Paul Cammish <sympl@kelduum.net>
# Copyright 2019, Paul Cammish <sympl@kelduum.net>, part of the Sympl Project.
#
# Licenced under GPL3+
#
......@@ -109,6 +109,45 @@ _is_database() {
# Base #
##############################################################################
_base_none() {
echo "Sympl command-line - a basic parser for common system administraton tasks.
Usage: sympl [function] [action] [target]
Where function is one of:
web, mail, mysql, dns, ftp, cron, backup or blank for the system itself.
And action is one of:
create, enable, disable, audit, update, destroy, set <item|option> <value>
And target is the domain/email address/database/etc.
Useful things:
- Other than using set, the function, action and target can be in any order.
- 'set' requires two arguments immediately after it, the option and value.
- If more permissions are needed, you'll be prompted for your password.
- 'destory' will only destroy something which has already been disabled.
Examples:
sympl web create example.com
sympl mysql disable example_db
sympl enable mail username@example.com
sympl audit backup
sympl destroy cron example.com
sympl example.com set only-ssl on
sympl update
Note: Not all functions are implimented yet.
Please report bugs via http://bugs.sympl.host.
"
}
_base_create() {
_noop
}
......@@ -134,13 +173,20 @@ _base_audit() {
}
_base_update() {
_noop
_debug "Updating Apt"
sudo apt-get -qq update
_debug "Upgrading installed packages"
sudo apt-get -q -y install --only-upgrade 'sympl-*'
}
##############################################################################
# Web #
##############################################################################
_web_none() {
_noop
}
_web_create() {
_is_domain $1
......@@ -230,15 +276,20 @@ _web_audit() {
}
_web_set() {
_noop
}
_web_update() {
_noop
}
##############################################################################
# Mysql/MariaDB #
##############################################################################
_mysql_none() {
_noop
}
_mysql_create() {
......@@ -340,31 +391,43 @@ _mysql_audit() {
mysql -e 'use mysql; select User from user;'
}
_mysql_update() {
_noop
}
##############################################################################
# FTP #
# DNS #
##############################################################################
_ftp_create() {
_dns_none() {
_noop
}
_ftp_enable() {
_dns_create() {
_noop
}
_ftp_disable() {
_dns_enable() {
_noop
}
_ftp_destroy() {
_dns_disable() {
_noop
}
_ftp_set() {
_dns_destroy() {
_noop
}
_ftp_audit() {
_dns_set() {
_noop
}
_dns_audit() {
_noop
}
_dns_update() {
_noop
}
......@@ -372,6 +435,10 @@ _ftp_audit() {
# Mail #
##############################################################################
_mail_none() {
_noop
}
_mail_create() {
_noop
}
......@@ -400,6 +467,10 @@ _mail_audit() {
# FTP #
##############################################################################
_ftp_none() {
_noop
}
_ftp_create() {
_noop
}
......@@ -424,10 +495,18 @@ _ftp_audit() {
_noop
}
_ftp_update() {
_noop
}
##############################################################################
# Backup #
##############################################################################
_backup_none() {
_noop
}
_backup_create() {
_verbose "Taking backup..."
sudo backup2l -b
......@@ -470,10 +549,18 @@ _backup_audit() {
backup2l -s
}
_backup_audit() {
_noop
}
##############################################################################
# Cron #
##############################################################################
_cron_none() {
_noop
}
_cron_create() {
_noop
}
......@@ -498,13 +585,17 @@ _cron_audit() {
_noop
}
_cron_update() {
_noop
}
##############################################################################
# NoOp Stub #
##############################################################################
_noop() {
_warn "This doesn't do anything yet."
_warn "Sorry this doesn't do anything yet, but it may be in a new version.\n Run 'sympl update' for an updated version."
exit 0
}
......@@ -514,8 +605,6 @@ _noop() {
_main() {
_debug "Command line parameters: $@"
UNHANDLED=()
while [ $# -gt 0 ]; do
case $1 in
......@@ -533,6 +622,7 @@ _main() {
enable) _action 'enable' ; shift ;;
disable) _action 'disable' ; shift ;;
audit|list) _action 'audit' ; shift ;;
update|upgrade) _action 'update' ; shift ;;
set) _action 'set' "$2" "$3" ; shift ; shift ; shift ;;
*) # unhandled parameter
if [ $TARGET = all ]; then
......@@ -545,6 +635,10 @@ _main() {
esac
done
_debug "Command line parameters: $@"
_debug "Running as '$I_AM', EUID '$EUID'"
_debug "Runtime variables:
Unhanded | $UNHANDLED
FUNCTION | $FUNCTION
......@@ -554,7 +648,7 @@ _main() {
SETTING | $SETTING"
if [ "x$UNHANDLED" != "x" ]; then
_help
_error "Unexpected input: '$UNHANDLED', run 'sympl' for help."
fi
_${FUNCTION}_${ACTION} $TARGET $OPTION $SETTING
......
sympl-core (10.0.190705.0) stable; urgency=medium
* Updated 'sympl' parser, added 'sympl update' function.
-- Paul Cammish <sympl@kelduum.net> Fri, 05 Jul 2019 13:01:00 +0100
sympl-core (10.0.190704.0) stable; urgency=medium
* Workaround for sympl-ssl bug #249 under IPv6 only.
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment