Compare commits
No commits in common. 'c8c998b6ed7e5c4d0d2e7bf6716209a8a8928b77' and '0d93018a00cacfbcac7f10b7ae67dcfff50188bb' have entirely different histories.
c8c998b6ed
...
0d93018a00
@ -0,0 +1,139 @@ |
||||
#! /usr/bin/env python |
||||
|
||||
# Imports |
||||
|
||||
from collections import OrderedDict |
||||
import inspect |
||||
import sys |
||||
|
||||
# Set path before importing overlays. |
||||
sys.path.append("../") |
||||
|
||||
# Import overlays |
||||
from scripttease.library.overlays.common import COMMON_MAPPINGS |
||||
from scripttease.library.overlays.centos import MAPPINGS as CENTOS_MAPPINGS |
||||
from scripttease.library.overlays.django import DJANGO_MAPPINGS |
||||
from scripttease.library.overlays.mysql import MYSQL_MAPPINGS |
||||
from scripttease.library.overlays.pgsql import PGSQL_MAPPINGS |
||||
from scripttease.library.overlays.posix import POSIX_MAPPINGS |
||||
from scripttease.library.overlays.ubuntu import MAPPINGS as UBUNTU_MAPPINGS |
||||
|
||||
# Functions |
||||
|
||||
|
||||
# https://stackoverflow.com/a/52003056/241720 |
||||
def get_signature(fn): |
||||
params = inspect.signature(fn).parameters |
||||
args = [] |
||||
kwargs = OrderedDict() |
||||
for p in params.values(): |
||||
if p.default is p.empty: |
||||
args.append(p.name) |
||||
else: |
||||
kwargs[p.name] = p.default |
||||
return args, kwargs |
||||
|
||||
|
||||
def print_description(text): |
||||
print(text) |
||||
print("") |
||||
|
||||
|
||||
def print_heading(title): |
||||
print(title) |
||||
print("=" * len(title)) |
||||
print("") |
||||
|
||||
|
||||
def print_mapping(commands, excludes=None): |
||||
keys = list(commands.keys()) |
||||
keys.sort() |
||||
|
||||
_excludes = excludes or dict() |
||||
|
||||
for key in keys: |
||||
if key in _excludes: |
||||
continue |
||||
|
||||
func = commands[key] |
||||
|
||||
docstring = func.__doc__ |
||||
if not docstring: |
||||
continue |
||||
|
||||
print(key) |
||||
print("-" * len(key)) |
||||
print("") |
||||
for i in docstring.split("\n"): |
||||
print(i.strip()) |
||||
# print("") |
||||
|
||||
print(".. code-block:: ini") |
||||
print("") |
||||
print(" [run %s command]" % key) |
||||
|
||||
args, kwargs = get_signature(func) |
||||
|
||||
line = list() |
||||
for a in args: |
||||
if a != "kwargs": |
||||
line.append(a) |
||||
|
||||
print(" %s: %s" % (key, " ".join(line))) |
||||
|
||||
for option, value in kwargs.items(): |
||||
if value is True: |
||||
_value = "yes" |
||||
elif value is False: |
||||
_value = "no" |
||||
else: |
||||
_value = value |
||||
|
||||
print(" %s: %s" % (option, value)) |
||||
|
||||
print("") |
||||
|
||||
|
||||
# Overlay output. |
||||
print(".. generated by generate_command_signatures.py") |
||||
print("") |
||||
|
||||
print_heading("Common") |
||||
print_description("Common commands are available to all overlays.") |
||||
print_mapping(COMMON_MAPPINGS) |
||||
|
||||
print_heading("Django") |
||||
print_description("Django commands are available to all overlays.") |
||||
print_mapping(DJANGO_MAPPINGS) |
||||
|
||||
print_heading("MySQL") |
||||
print_description("MySQL commands.") |
||||
print_mapping(MYSQL_MAPPINGS) |
||||
|
||||
print_heading("Postgres") |
||||
print_description("Postgres commands.") |
||||
print_mapping(PGSQL_MAPPINGS) |
||||
|
||||
print_heading("POSIX") |
||||
print_description("Posix commands form the basis of overlays for *nix platforms.") |
||||
print_mapping(POSIX_MAPPINGS, excludes=["func"]) |
||||
|
||||
exclude_from_centos = COMMON_MAPPINGS.copy() |
||||
exclude_from_centos.update(DJANGO_MAPPINGS) |
||||
exclude_from_centos.update(MYSQL_MAPPINGS) |
||||
exclude_from_centos.update(PGSQL_MAPPINGS) |
||||
exclude_from_centos.update(POSIX_MAPPINGS) |
||||
print_heading("Cent OS") |
||||
print_description("The Cent OS overlay incorporates commands specific to that platform as well as commands from " |
||||
"common, Django, MySQL, Postgres, and POSIX.") |
||||
print_mapping(CENTOS_MAPPINGS, excludes=exclude_from_centos) |
||||
|
||||
exclude_from_ubuntu = COMMON_MAPPINGS.copy() |
||||
exclude_from_ubuntu.update(DJANGO_MAPPINGS) |
||||
exclude_from_ubuntu.update(MYSQL_MAPPINGS) |
||||
exclude_from_ubuntu.update(PGSQL_MAPPINGS) |
||||
exclude_from_ubuntu.update(POSIX_MAPPINGS) |
||||
print_heading("Ubuntu") |
||||
print_description("The Ubuntu overlay incorporates commands specific to that platform as well as commands from " |
||||
"common, Django, MySQL, Postgres, and POSIX.") |
||||
print_mapping(UBUNTU_MAPPINGS, excludes=exclude_from_ubuntu) |
|
Before Width: | Height: | Size: 33 KiB |
Before Width: | Height: | Size: 301 KiB After Width: | Height: | Size: 301 KiB |
Before Width: | Height: | Size: 393 KiB After Width: | Height: | Size: 393 KiB |
Before Width: | Height: | Size: 33 KiB After Width: | Height: | Size: 33 KiB |
Before Width: | Height: | Size: 111 KiB After Width: | Height: | Size: 111 KiB |
Before Width: | Height: | Size: 181 KiB After Width: | Height: | Size: 181 KiB |
@ -0,0 +1,86 @@ |
||||
.. _commands: |
||||
|
||||
******** |
||||
Commands |
||||
******** |
||||
|
||||
.. code-block:: text |
||||
|
||||
usage: tease [-h] [-c] [-C= VARIABLES] [-d] [-D] [-f= FILTERS] [-O= OPTIONS] [-s] [-T= TEMPLATE_LOCATIONS] [-w= OUTPUT_FILE] [-V= VARIABLES_FILE] |
||||
[-v] [--version] |
||||
[path] |
||||
|
||||
positional arguments: |
||||
path The path to the configuration file. |
||||
|
||||
optional arguments: |
||||
-h, --help show this help message and exit |
||||
-c, --color Enable code highlighting for terminal output. |
||||
-C= VARIABLES, --context= VARIABLES |
||||
Context variables for use in pre-parsing the config and templates. In the form of: name:value |
||||
-d, --docs Output documentation instead of code. |
||||
-D, --debug Enable debug output. |
||||
-f= FILTERS, --filter= FILTERS |
||||
Filter the commands in the form of: attribute:value |
||||
-O= OPTIONS, --option= OPTIONS |
||||
Common command options in the form of: name:value |
||||
-s, --script Output commands as a script. |
||||
-T= TEMPLATE_LOCATIONS, --template-path= TEMPLATE_LOCATIONS |
||||
The location of template files that may be used with the template command. |
||||
-w= OUTPUT_FILE, --write= OUTPUT_FILE |
||||
Write the output to disk. |
||||
-V= VARIABLES_FILE, --variables-file= VARIABLES_FILE |
||||
Load variables from a file. |
||||
-v Show version number and exit. |
||||
--version Show verbose version information and exit. |
||||
|
||||
NOTES |
||||
|
||||
This command is used to parse configuration files and output the commands. |
||||
|
||||
Using the Tease Command |
||||
======================= |
||||
|
||||
The ``tease`` command may be used to parse a configuration file, providing additional utilities for working with commands. |
||||
|
||||
The ``path`` argument defaults to ``commands.ini``. |
||||
|
||||
Context Variables May be Provided on the Command Line |
||||
----------------------------------------------------- |
||||
|
||||
To supply context variables on the command line: |
||||
|
||||
.. code-block:: bash |
||||
|
||||
tease -C domain_name:example.com -C domain_tld:example_com |
||||
|
||||
Loading Context Variables from a File |
||||
------------------------------------- |
||||
|
||||
Context variables may be loaded from a file: |
||||
|
||||
.. code-block:: ini |
||||
|
||||
[domain] |
||||
name = example.com |
||||
tld = example_com |
||||
|
||||
The variables above are available as ``section_key``. For example, ``domain_name`` is ``example.com``. |
||||
|
||||
.. code-block:: bash |
||||
|
||||
tease -V variables.ini |
||||
|
||||
Setting Common Options for All Commands |
||||
--------------------------------------- |
||||
|
||||
Rather than include a common parameter in the configuration file, it is possible to specify a common option on the command line. |
||||
|
||||
.. code-block:: bash |
||||
|
||||
tease -O sudo:yes |
||||
|
||||
The Difference Between Variables and Options |
||||
-------------------------------------------- |
||||
|
||||
Variables are used to pre-process configuration files as templates, while common options are passed to *all* command instances. |
@ -1,77 +0,0 @@ |
||||
************ |
||||
Contributing |
||||
************ |
||||
|
||||
We welcome contributions to this and any of `our open source projects`_. There are a number of ways to participate and contribute. See :ref:`contact`. |
||||
|
||||
.. _our open source projects: https://docs.diff6.com |
||||
|
||||
Issue Management |
||||
================ |
||||
|
||||
Reporting Issues |
||||
---------------- |
||||
|
||||
If you have found a bug or error in the documentation, please submit a request. See :ref:`contact`. |
||||
|
||||
.. important:: |
||||
Do **not** report security issues using the issue tracker. Instead, send an email to security@develmaycare.com with details on the issue you've discovered. |
||||
|
||||
Submitting Feature Requests |
||||
--------------------------- |
||||
|
||||
Although we reserve the right to decline new features, we welcome all feature requests. See :ref:`contact`. |
||||
|
||||
Testing and Quality Control |
||||
--------------------------- |
||||
|
||||
Testing involves using Script Tease in real life or in development. Feel free to report any issues you find, or to improve the unit tests. |
||||
|
||||
Pull Requests |
||||
------------- |
||||
|
||||
Pull requests are welcome. Such requests should be associated with an issue. We may ignore pull requests that do not have a corresponding issue, so create an issue if one does not already exist. |
||||
|
||||
Promotion |
||||
========= |
||||
|
||||
You may help spread awareness of Script Tease by writing blog posts. We are happy to link out to reviews and tutorials from our web site. `Let us know if you've created a blog post`_ that we can share. Be sure to include a link to the post. |
||||
|
||||
You may also provide us with a guest post to be included on our blog. |
||||
|
||||
.. _Let us know if you've created a blog post: https://develmaycare.com/contact/?product=Script%20Tease |
||||
|
||||
.. note:: |
||||
We reserve the right to proof and approve or decline all content posted on our web site. |
||||
|
||||
Development |
||||
=========== |
||||
|
||||
Setting Up For Development |
||||
-------------------------- |
||||
|
||||
1. Clone the repo at https://github.com/develmaycare/python-scripttease |
||||
2. Create a virtual environment and install the requirements from ``requirements.pip`` |
||||
|
||||
Style Guide |
||||
----------- |
||||
|
||||
Script Tease follows `PEP8`_ and (where appropriate) the `Django style guide`_ and `JavaScript Standard Style`_. |
||||
|
||||
.. _Django style guide: https://docs.djangoproject.com/en/stable/internals/contributing/writing-code/coding-style/ |
||||
.. _JavaScript Standard Style: https://standardjs.com |
||||
.. _PEP8: https://www.python.org/dev/peps/pep-0008/ |
||||
|
||||
We *do* make a few exceptions and provide additional guidance which is documented in our `developer docs`_. |
||||
|
||||
.. _developer docs: https://docs.develmaycare.com/en/developer/ |
||||
|
||||
Dependencies |
||||
------------ |
||||
|
||||
.. include:: _includes/dependencies.rst |
||||
|
||||
Testing |
||||
------- |
||||
|
||||
.. include:: _includes/tests.rst |
@ -0,0 +1,32 @@ |
||||
.. _getting-started: |
||||
|
||||
*************** |
||||
Getting Started |
||||
*************** |
||||
|
||||
System Requirements |
||||
=================== |
||||
|
||||
Python 3.6 or greater is required. |
||||
|
||||
Install |
||||
======= |
||||
|
||||
To install: |
||||
|
||||
.. code-block:: bash |
||||
|
||||
pip install python-scripttease; |
||||
|
||||
Configuration |
||||
============= |
||||
|
||||
See :ref:`topics-configuration` for creating a command configuration file. |
||||
|
||||
FAQs |
||||
==== |
||||
|
||||
Have a question? `Just ask`_! |
||||
|
||||
.. _Just ask: https://develmaycare.com/contact/?product=Script%20Tease |
||||
|
@ -0,0 +1,236 @@ |
||||
.. _how-to: |
||||
|
||||
****** |
||||
How To |
||||
****** |
||||
|
||||
Create a New Command Overlay |
||||
============================ |
||||
|
||||
:ref:`topics-overlays` are used to define the commands supported by a given application, service, or operating system. Commands are defined as a function. |
||||
|
||||
1) Define a Module |
||||
------------------ |
||||
|
||||
The first step is to create a new module in which functions will be defined. |
||||
|
||||
.. code-block:: python |
||||
|
||||
# module_name.py |
||||
from ..commands import Command |
||||
|
||||
For overlays that represent an operating system, the ``command_exists()`` function is required: |
||||
|
||||
.. code-block:: python |
||||
|
||||
def command_exists(name): |
||||
return name in MAPPINGS |
||||
|
||||
|
||||
2) Define Command Function |
||||
-------------------------- |
||||
|
||||
The purpose of each function is to provide an interface for instantiating a :py:class:`scripttease.library.commands.base.Command` instance. The example below is taken from the ``posix`` module. |
||||
|
||||
.. code-block:: python |
||||
|
||||
# module_name.py |
||||
# ... |
||||
|
||||
def mkdir(path, mode=None, recursive=True, **kwargs): |
||||
"""Create a directory. |
||||
|
||||
- path (str): The path to be created. |
||||
- mode (int | str): The access permissions of the new directory. |
||||
- recursive (bool): Create all directories along the path. |
||||
|
||||
""" |
||||
kwargs.setdefault("comment", "create directory %s" % path) |
||||
|
||||
statement = ["mkdir"] |
||||
if mode is not None: |
||||
statement.append("-m %s" % mode) |
||||
|
||||
if recursive: |
||||
statement.append("-p") |
||||
|
||||
statement.append(path) |
||||
|
||||
return Command(" ".join(statement), **kwargs) |
||||
|
||||
The arguments and any specific keyword arguments are automatically used by the parser, but also serve as a simple interface for programmatic use. |
||||
|
||||
Each function *must* also accept ``**kwargs`` and should set a default for ``comment`` as above. |
||||
|
||||
.. important:: |
||||
Rather than the usual Spinx-based documentation, define the docstring as shown above. This is used to automatically create the documentation for the command. |
||||
|
||||
3) Add Functions to the Mapping |
||||
------------------------------- |
||||
|
||||
The final step adds the function to the mapping. This makes it available to the command factory. |
||||
|
||||
.. code-block:: python |
||||
|
||||
# module_name.py |
||||
# ... |
||||
|
||||
MAPPINGS = { |
||||
'mkdir': mkdir, |
||||
} |
||||
|
||||
For overlays that represent an operating system, ``MAPPINGS`` is required -- in addition to ``command_exists()`` above. For commands that are specific to service or application, the name of the dictionary may be anything that is appropriate. For example, ``DJANGO_MAPPINGS``. |
||||
|
||||
Additionally, for an operating system overlay, you may wish to import other mappings and incorporate them into ``MAPPINGS``. |
||||
|
||||
.. code-block:: python |
||||
|
||||
# module_name.py |
||||
from ..commands import Command |
||||
from .common import COMMON_MAPPINGS |
||||
from .django import DJANGO_MAPPINGS |
||||
from .pgsql import PGSQL_MAPPINGS |
||||
|
||||
MAPPINGS = { |
||||
# ... |
||||
} |
||||
|
||||
MAPPINGS.update(COMMON_MAPPINGS) |
||||
MAPPINGS.update(DJANGO_MAPPINGS) |
||||
MAPPINGS.update(PGSQL_MAPPINGS) |
||||
|
||||
4) Update Documentation |
||||
----------------------- |
||||
|
||||
Add the command mappings to the ``docs/generate_command_signatures.py`` file. See the script for more details. |
||||
|
||||
Export Commands as a Script |
||||
=========================== |
||||
|
||||
You can export commands as a read-to-use script. For example: |
||||
|
||||
.. code-block:: python |
||||
|
||||
config = Config("commands.ini") |
||||
if not config.load(): |
||||
print("Bummer!") |
||||
exit() |
||||
|
||||
script = config.as_script() |
||||
print(script) |
||||
|
||||
Post a Message to Slack |
||||
======================= |
||||
|
||||
The slack function may be used to send a message to a Slack channel. This uses the Incoming Webhooks feature, which requires some additional setup. |
||||
|
||||
.. note:: |
||||
The following steps were accurate as of September 2020. |
||||
|
||||
**1.** Log in to Slack and go to `Your Apps`_. |
||||
|
||||
.. _Your Apps: https://api.slack.com/apps |
||||
|
||||
**2.** Create a new Slack app. |
||||
|
||||
**3.** On the next page, select Incoming Webhooks and then toggle activation. |
||||
|
||||
.. image:: /_static/images/slack-1.jpg |
||||
|
||||
**4.** Next click Add new Webhook to Workspace and select the channel to which the message will be posted. |
||||
|
||||
.. image:: /_static/images/slack-2.jpg |
||||
|
||||
.. image:: /_static/images/slack-3.jpg |
||||
|
||||
**5.** Copy the URL for the new webhook to use as the ``url`` parameter for the Slack command. |
||||
|
||||
.. code-block:: ini |
||||
|
||||
[send a message to slack] |
||||
slack: "This is a test message." |
||||
url: the URL you created goes here |
||||
|
||||
Post a Message to Twist |
||||
======================= |
||||
|
||||
The twist function may be used to send a message to Twist, which requires some additional setup. |
||||
|
||||
.. note:: |
||||
The following steps were accurate as of September 2020. |
||||
|
||||
**1.** Log in to Twist and from the profile menu go to Add Integrations. Then click on Build and "Add a new integration". |
||||
|
||||
**2.** Provide the requested info. |
||||
|
||||
.. image:: _static/images/twist-1.png |
||||
|
||||
**3.** After submitting this info, go to Installation. Select a channel and who to notify. Then click "Install integration". |
||||
|
||||
.. image:: _static/images/twist-2.png |
||||
|
||||
**4.** Copy the "Post content manually" URL for use in your configuration file. |
||||
|
||||
.. code-block:: ini |
||||
|
||||
[post a message to twist] |
||||
twist: "This is a test message." |
||||
url: the URL you created goes here |
||||
|
||||
Use Script Tease With Common Kit |
||||
================================ |
||||
|
||||
Since the focus of Script Tease is to convert plain text instructions into valid command line statements, it does *not* provide support for executing those statements either locally or remotely. However, The shell component of `python-commonkit`_ *does* provide support for executing commands in local POSIX environments. |
||||
|
||||
.. _python-commonkit: https://docs.develmaycare.com/en/python-commonkit/stable/components/#module-commonkit.shell |
||||
|
||||
Here is an example of how to use these packages together: |
||||
|
||||
.. code-block:: python |
||||
|
||||
from commonkit.shell import Command |
||||
from scripttease.parsers.utils import load_commands |
||||
|
||||
def execute(step): |
||||
command = Command( |
||||
step.statement, |
||||
comment=step.comment, |
||||
path=step.cd, |
||||
prefix=step.prefix, |
||||
shell=step.shell |
||||
) |
||||
|
||||
# Sudo is a different class, but identical in behavior. |
||||
command.sudo = step.sudo |
||||
|
||||
if command.run(): |
||||
print("[success] %s" % step.comment) |
||||
else: |
||||
print("[failure] %s" % step.comment) |
||||
if step.stop: |
||||
print("I can't go on: %s" % command.error) |
||||
exit(command.code) |
||||
|
||||
# Load SCRIPT TEASE commands from an INI file. These are instances of either Command or ItemizedCommand found in |
||||
# scripttease.library.commands |
||||
steps = load_commands("path/to/steps.ini") |
||||
|
||||
# A failure to load results in None. |
||||
if steps is None: |
||||
print("Failed to load steps.") |
||||
exit(1) |
||||
|
||||
# Iterate through each step to create a COMMON KIT command. |
||||
for step in steps: |
||||
|
||||
# To preview ... |
||||
# print(step.get_statement(cd=True)) |
||||
|
||||
if step.is_itemized: |
||||
for substep in step.get_commands(): |
||||
execute(substep) |
||||
else: |
||||
execute(step) |
||||
|
||||
Common Kit is already a dependency of Script Tease so it is installed by default. The ``execute()`` function is a shortcut that helps deal with itemized commands. The path (``step.cd``) is automatically handled by Common Kit's Command class. |
||||
|
@ -0,0 +1,140 @@ |
||||
******* |
||||
Project |
||||
******* |
||||
|
||||
Contributing |
||||
============ |
||||
|
||||
We welcome contributions to this and any of `our open source projects`_. There are a number of ways to participate and contribute. See :ref:`contact`. |
||||
|
||||
.. _our open source projects: https://develmaycare.com/products/ |
||||
|
||||
Reporting Issues |
||||
---------------- |
||||
|
||||
Perhaps the easiest way to contribute is to submit an issue. If you have found a bug or error in the documentation, please submit a request. See :ref:`contact`. |
||||
|
||||
.. important:: |
||||
Do **not** report security issues using the issue tracker. Instead, send an email to security@develmaycare.com with details on the issue you've discovered. |
||||
|
||||
Submitting Feature Requests |
||||
--------------------------- |
||||
|
||||
Although we reserve the right to decline new features, we welcome all feature requests. See :ref:`contact`. |
||||
|
||||
Testing and Quality Control |
||||
--------------------------- |
||||
|
||||
Testing involves using Script Tease in real life or in development. Feel free to report any issues you find, or to improve the unit tests. |
||||
|
||||
Pull Requests |
||||
------------- |
||||
|
||||
Pull requests are welcome. Such requests should be associated with an issue. We may ignore pull requests that do not have a corresponding issue, so create an issue if one does not already exist. |
||||
|
||||
Blogging |
||||
-------- |
||||
|
||||
You may help spread awareness of Script Tease by writing blog posts. We are happy to link out to reviews and tutorials from our web site. `Let us know if you've created a blog post`_ that we can share. Be sure to include a link to the post. |
||||
|
||||
You may also provide us with a guest post to be included on our blog. |
||||
|
||||
.. _Let us know if you've created a blog post: https://develmaycare.com/contact/?product=Script%20Tease |
||||
|
||||
.. note:: |
||||
We reserve the right to proof and approve or decline all content posted on our web site. |
||||
|
||||
Development |
||||
=========== |
||||
|
||||
Setting Up For Development |
||||
-------------------------- |
||||
|
||||
1. Clone the repo at https://github.com/develmaycare/python-scripttease |
||||
2. Create a virtual environment and install the requirements from ``requirements.pip`` |
||||
3. See :ref:`how-to`. |
||||
|
||||
Style Guide |
||||
----------- |
||||
|
||||
Script Tease follows `PEP8`_ and (where appropriate) the `Django style guide`_ and `JavaScript Standard Style`_. |
||||
|
||||
.. _Django style guide: https://docs.djangoproject.com/en/stable/internals/contributing/writing-code/coding-style/ |
||||
.. _JavaScript Standard Style: https://standardjs.com |
||||
.. _PEP8: https://www.python.org/dev/peps/pep-0008/ |
||||
|
||||
We *do* make a few exceptions and provide additional guidance which is documented in our `developer docs`_. |
||||
|
||||
.. _developer docs: https://docs.develmaycare.com/en/developer/ |
||||
|
||||
Dependencies |
||||
============ |
||||
|
||||
.. include:: _includes/project-dependencies.rst |
||||
|
||||
Tests |
||||
===== |
||||
|
||||
.. include:: _includes/project-tests.rst |
||||
|
||||
Releasing |
||||
========= |
||||
|
||||
Versioning |
||||
---------- |
||||
|
||||
Script Tease follows a loose form of `semantic versioning`_. The use of semantic versioning makes it clear when deprecation occurs and backward compatibility is removed. Documented incompatibilities may still exist where deprecation is not feasible (technically or financially). |
||||
|
||||
.. _semantic versioning: https://semver.org/ |
||||
|
||||
Cadence |
||||
------- |
||||
|
||||
New features (and especially new overlays) are planned for release every 3 months. Patch-level changes (to fix bugs or security issues) are always released as needed. |
||||
|
||||
Long-Term Support |
||||
----------------- |
||||
|
||||
Some releases may be designated as long-term support (LTS) releases. Such releases will have security and critical bug fixes applied for 6 months. |
||||
|
||||
Deprecation Policy |
||||
------------------ |
||||
|
||||
Minor releases may deprecate features from a previous minor release. For example, if a feature is deprecated in release 1.1, it will continue to work in the 1.2 release, though warnings may be raised. However, the deprecated feature may be removed in release 1.3 and may not function as previously expected or will raise errors. |
||||
|
||||
Major releases may *always* remove deprecated features. |
||||
|
||||
Patch-level releases *never* remove deprecated features. |
||||
|
||||
Legal |
||||
===== |
||||
|
||||
.. code-block:: text |
||||
|
||||
Copyright (c) Pleasant Tents, LLC |
||||
|
||||
All rights reserved. |
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, |
||||
are permitted provided that the following conditions are met: |
||||
|
||||
* Redistributions of source code must retain the above copyright notice, |
||||
this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright notice, |
||||
this list of conditions and the following disclaimer in the documentation |
||||
and/or other materials provided with the distribution. |
||||
* Neither the name of Pleasant Tents, LLC nor the names of its contributors |
||||
may be used to endorse or promote products derived from this software |
||||
without specific prior written permission. |
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
@ -1,29 +0,0 @@ |
||||
******** |
||||
Releases |
||||
******** |
||||
|
||||
Versioning |
||||
========== |
||||
|
||||
Script Tease follows a loose form of `semantic versioning`_. The use of semantic versioning makes it clear when deprecation occurs and backward compatibility is removed. Documented incompatibilities may still exist where deprecation is not feasible (technically or financially). |
||||
|
||||
.. _semantic versioning: https://semver.org/ |
||||
|
||||
Cadence |
||||
======= |
||||
|
||||
New features (and especially new overlays) are planned for release every 3 months. Patch-level changes (to fix bugs or security issues) are always released as needed. |
||||
|
||||
Long-Term Support |
||||
================= |
||||
|
||||
Some releases may be designated as long-term support (LTS) releases. Such releases will have security and critical bug fixes applied for 6 months. |
||||
|
||||
Deprecation Policy |
||||
================== |
||||
|
||||
Minor releases may deprecate features from a previous minor release. For example, if a feature is deprecated in release 1.1, it will continue to work in the 1.2 release, though warnings may be raised. However, the deprecated feature may be removed in release 1.3 and may not function as previously expected or will raise errors. |
||||
|
||||
Major releases may *always* remove deprecated features. |
||||
|
||||
Patch-level releases *never* remove deprecated features. |
@ -0,0 +1,115 @@ |
||||
.. _topics-configuration: |
||||
|
||||
************* |
||||
Configuration |
||||
************* |
||||
|
||||
Generating Commands From a File |
||||
=============================== |
||||
|
||||
The :py:class:`scripttease.parsers.ini.Config` class may instantiate commands by loading a configuration file. |
||||
|
||||
.. note:: |
||||
Additional formats such as JSON or YAML may be supported in the future. |
||||
|
||||
An example file: |
||||
|
||||
.. code-block:: ini |
||||
|
||||
[install apache] |
||||
install: apache2 |
||||
|
||||
[create the web site directory] |
||||
mkdir: /var/www/domains/example_com/www |
||||
recursive: yes |
||||
|
||||
[set permissions on the website directory] |
||||
perms: /var/www/domains/example_com/www |
||||
group: www-data |
||||
mode: 775 |
||||
owner: www-data |
||||
|
||||
Notes regarding this format: |
||||
|
||||
- This is the standard format for Python's ConfigParser. If you prefer, you may use ``=`` instead of ``:``. |
||||
- The first part of each command is the INI section and is used as the default comment. |
||||
- The command name *must* be the *first* option in the section. |
||||
- The arguments for the command appear as the value of the first option in the section. Arguments are separated by a |
||||
space. |
||||
- Arguments that should be treated as a single value should be enclosed in double quotes. |
||||
- ``yes`` and ``no`` are interpreted as boolean values. |
||||
- List values, where required, are separated by commas. |
||||
|
||||
.. _topics-configuration-common-parameters: |
||||
|
||||
Common Parameters |
||||
----------------- |
||||
|
||||
All commands support the following common parameters: |
||||
|
||||
- ``comment``: A comment regarding the command. |
||||
- ``condition``: A condition for execution. For example, ``! -f /path/to/some/file.txt`` |
||||
- ``cd``: The path from which a command should be executed. |
||||
- ``environments``: A string or list of comma-separated strings indicating the operational environments in which the command runs. This is *not* used by default, but may be used to programmatically filter commands for a specific environment. For example, development versus live. |
||||
- ``prefix``: A statement to be added prior to executing the command. |
||||
- ``register``: A variable name to which the the success or failure (exit code) of the statement is captured. |
||||
- ``shell``: The shell used to run the commands. For example, ``/bin/bash``. This is generally not important, but can be a problem when attempting to execute some commands (such as Django management commands). |
||||
- ``stop``: ``True`` indicates no other commands should be executed if the given command fails. |
||||
- ``sudo``: ``True`` indicates the command should be automatically prefixed with ``sudo``. If provided as a string, the command is also prefixed with a specific user name. |
||||
- ``tags``: A list of tags used to classify the command. |
||||
|
||||
Defining an "Itemized" Command |
||||
------------------------------ |
||||
|
||||
Certain command definitions may be repeated by defining a list of items. |
||||
|
||||
Example of an "itemized" command: |
||||
|
||||
.. code-block:: ini |
||||
|
||||
[create multiple directories] |
||||
mkdir: /var/www/domains/example_com/$item |
||||
items: www, www/assets, www/content |
||||
recursive: yes |
||||
|
||||
[touch a bunch of files] |
||||
touch: /var/www/domains/example_com/www/$item |
||||
items: index.html, assets/index.html, content/index.html |
||||
|
||||
.. note:: |
||||
Command itemization may vary with the command type. |
||||
|
||||
Pre-Parsing Command Files as Templates |
||||
====================================== |
||||
|
||||
Configuration file may be pre-processed as a Jinja2 template by providing a context dictionary: |
||||
|
||||
.. code-block:: ini |
||||
|
||||
[install apache] |
||||
install: apache |
||||
|
||||
[create the website directory] |
||||
mkdir: /var/www/domains/{{ domain_tld }}/www |
||||
recursive: yes |
||||
|
||||
[set permissions on the website directory] |
||||
perms: /var/www/domains/{{ domain_tld }}/www |
||||
group: www-data |
||||
mode: 775 |
||||
owner: www-data |
||||
|
||||
Then with a config instance: |
||||
|
||||
.. code-block:: python |
||||
|
||||
context = { |
||||
'domain_tld': "example_com", |
||||
} |
||||
|
||||
config = Config("commands.ini", context=context) |
||||
config.load() |
||||
|
||||
for command in config.get_commands(): |
||||
print(command.get_statement(cd=True)) |
||||
print("") |
@ -0,0 +1,24 @@ |
||||
.. _topics-overlays: |
||||
|
||||
******** |
||||
Overlays |
||||
******** |
||||
|
||||
An overlay is a collection of functions that provide an interface to command creation. An overlay allows configuration files to specify commands in a generic way. When the file is loaded, an overlay may be specified which Script Tease uses to generate commands that are specific to a given operating system. |
||||
|
||||
There are currently four (5) general and re-usable overlays: |
||||
|
||||
- common |
||||
- django |
||||
- mysql |
||||
- pgsql |
||||
- posix |
||||
|
||||
And two (2) overlays that are specific to operating systems: |
||||
|
||||
- centos |
||||
- ubuntu |
||||
|
||||
The examples that follow instantiate command instances from an INI file. Each example is shown with the defaults. All commands support a number of :ref:`topics-configuration-common-parameters`. |
||||
|
||||
.. include:: _includes/overlays.rst |
@ -0,0 +1,11 @@ |
||||
.. _topics: |
||||
|
||||
****** |
||||
Topics |
||||
****** |
||||
|
||||
.. toctree:: |
||||
:maxdepth: 2 |
||||
|
||||
Configuration <topics-configuration> |
||||
Overlays <topics-overlays> |
@ -0,0 +1,70 @@ |
||||
# PostgreSQL |
||||
|
||||
Summary: Work with Postgres databases. |
||||
|
||||
## Common Options |
||||
|
||||
- `admin_pass`: The password off the admin-authorized user. |
||||
- `admin_user`: The user name of the admin-authorized user. Default: `postgres` |
||||
- `host`: The host name. Default: `localhost` |
||||
- `port`: The TCP port. Default: `5432` |
||||
|
||||
## Available Commands |
||||
|
||||
### pgsql.create |
||||
|
||||
Create a database. Argument is the database name. |
||||
|
||||
- `owner`: The user name that owns the database. |
||||
|
||||
```ini |
||||
[create the database] |
||||
pgsql.create: database_name |
||||
``` |
||||
|
||||
### pgsql.drop |
||||
|
||||
Drop a database. Argument is the database name. |
||||
|
||||
### pgsql.dump |
||||
|
||||
Dump the database schema. Argument is the database name. |
||||
|
||||
- `path`: The path to the dump file. Default: `dump.sql` |
||||
|
||||
### pgsql.exec |
||||
|
||||
Execute an SQL statement. Argument is the SQL statement. |
||||
|
||||
- `database`: The name of the database where the statement will be executed. Default: `default` |
||||
|
||||
### pgsql.exists |
||||
|
||||
Determine if a database exists. Argument is the database name. |
||||
|
||||
### pgsql.user |
||||
|
||||
Create a user. Argument is the user name. |
||||
|
||||
- `password`: The user's password. |
||||
|
||||
```ini |
||||
[create a database user] |
||||
pgsql.user: username |
||||
``` |
||||
|
||||
Remove a user. |
||||
|
||||
```ini |
||||
[remove a database user] |
||||
pgsql.user: username |
||||
op: remove |
||||
``` |
||||
|
||||
Determine if a user exists. |
||||
|
||||
```ini |
||||
[determine if database user exists] |
||||
pgsql.user: username |
||||
op: exists |
||||
``` |
@ -0,0 +1,148 @@ |
||||
# POSIX |
||||
|
||||
Summary: Work with common POSIX-compliant commands.. |
||||
|
||||
## Available Commands |
||||
|
||||
### append |
||||
|
||||
Append content to a file. Argument is the file name. |
||||
|
||||
- `content`: The content to be appended. |
||||
|
||||
### archive |
||||
|
||||
Create an archive (tarball). Argument is the target file or directory. |
||||
|
||||
- `absolute`: Don't strip leading slashes from file names. |
||||
- `view`: View the progress. |
||||
- `exclude`: Exclude file name patterns. |
||||
- `strip`: Strip component paths to the given depth (integer). |
||||
- `to`: The path to where the archive will be created. |
||||
|
||||
### copy |
||||
|
||||
Copy a file or directory. First argument is the target file/directory. Second argument is the destination. |
||||
|
||||
- `overwrite`: Overwrite an existing target. |
||||
- `recursive`: Copy directories recursively. |
||||
|
||||
### dir |
||||
|
||||
Create a directory. Argument is the path. |
||||
|
||||
- `group`: Set the group to the given group name. |
||||
- `mode`: Set the mode on the path. |
||||
- `owner`: Set the owner to the given owner name. |
||||
- `recursive`: Create the full path even if intermediate directories do not exist. |
||||
|
||||
### extract |
||||
|
||||
Extract an archive (tarball). Argument is the path to the archive file. |
||||
|
||||
- `absolute`: Strip leading slashes from file names. |
||||
- `view`: View the progress. |
||||
- `exclude`: Exclude file name patterns. |
||||
- `strip`: Strip component paths to the given depth (integer). |
||||
- `to`: The path to where the archive will be extracted. Defaults to the current working directory. |
||||
|
||||
### file |
||||
|
||||
Create a file. Argument is the path. |
||||
|
||||
- `content`: The content of the file. Otherwise, an empty file is created. |
||||
- `group`: Set the group to the given group name. |
||||
- `mode`: Set the mode on the path. |
||||
- `owner`: Set the owner to the given owner name. |
||||
|
||||
### link |
||||
|
||||
Create a symlink. First argument is the target. Second argument is the destination. |
||||
|
||||
- `force`: Force creation of the link. |
||||
|
||||
### move |
||||
|
||||
Move a file or directory. First argument is the target. Second argument is the desitnation. |
||||
|
||||
### perms |
||||
|
||||
Set permissions on a file or directory. Argument is the path. |
||||
|
||||
- `group`: Set the group to the given group name. |
||||
- `mode`: Set the mode on the path. |
||||
- `owner`: Set the owner to the given owner name. |
||||
- `recursive`: Apply permission recursively (directories only). |
||||
|
||||
### push |
||||
|
||||
Push (rsync) a path to a remote server. First argument is the local path. Second argument is the remote path. |
||||
|
||||
- `delete`: Delete existing files/directories. |
||||
- `host`: The host name. Required. |
||||
- `key_file`: Use the given SSL (private) key. Required. |
||||
- `links`: Copy symlinks. |
||||
- `exclude`: Exclude patterns from the given (local) file. |
||||
- `port`: The TCP port on the host. Default: `22` |
||||
- `recursive`: Operate recursively on directories. |
||||
- `user`: The user name. Required. |
||||
|
||||
### remove |
||||
|
||||
Remove a file or directory. Argument is the path. |
||||
|
||||
- `force`: Force the removal. |
||||
- `recursive`: Remove (directories) rescurisvely. |
||||
|
||||
### rename |
||||
|
||||
Rename a file or directory. First argument is the target. Second argument is the destination. |
||||
|
||||
### replace |
||||
|
||||
Replace something in a file. First argument is the path. |
||||
|
||||
- `backup`: Create a backup. |
||||
- `delimiiter`: The sed delimiter. Default: `/` |
||||
- `find`: The text to be found. Required. |
||||
- `sub`: The text to be replaced. Required. |
||||
|
||||
### scopy |
||||
|
||||
Copy a file to a remote server. First argument is the local file name. Second argument is the remote destination. |
||||
|
||||
- `key_file`: The private key file to use for the connection. |
||||
- `host`: The host name. Required. |
||||
- `port`: The TCP port. Default: `22` |
||||
- `user`: The user name. Required. |
||||
|
||||
### ssl |
||||
|
||||
Use Let's Encrypt (certbot) to acquire an SSL certificate. Argument is the domain name. |
||||
|
||||
- `email`: The email address for "agree tos". Default: `webmaster@domain_name` |
||||
- `webroot`: The webroot to use. Default: `/var/www/maint/www` |
||||
|
||||
### sync |
||||
|
||||
Sync (rsync) local files and directories. First argument is the target. Second argument is the destination. |
||||
|
||||
- `delete`: Delete existing files/directories. |
||||
- `links`: Copy symlinks. |
||||
- `exclude`: Exclude patterns from the given (local) file. |
||||
- `recursive`: Operate recursively on directories. |
||||
|
||||
### touch |
||||
|
||||
Touch a file, whether it exists or not. Argument is the path. |
||||
|
||||
### wait |
||||
|
||||
Wait for n number of seconds before continuing. Argument is the number of seconds. |
||||
|
||||
### write |
||||
|
||||
Write to a file. Argument is the path. |
||||
|
||||
- `content`: The content to write to the file. Replaces existing content. |
||||
|
@ -0,0 +1,20 @@ |
||||
# Python |
||||
|
||||
Summary: Work with Python. |
||||
|
||||
## Available Commands |
||||
|
||||
### pip |
||||
|
||||
Use the pip command. Argument is the package name. |
||||
|
||||
- `op`: The operation; `install` (the default), `remove`, or `updgrade`. |
||||
- `venv`: The name of the virtual environment to use. |
||||
|
||||
### pip3 |
||||
|
||||
Use Python3 pip. See pip above. |
||||
|
||||
### virtualenv |
||||
|
||||
Create a python virtual environment. Argument is the environment name. |
@ -0,0 +1,24 @@ |
||||
# Getting Started |
||||
|
||||
## System Requirements |
||||
|
||||
Python 3.6 or greater is required. |
||||
|
||||
## Install |
||||
|
||||
To install: |
||||
|
||||
```bash |
||||
pip install python-scripttease; |
||||
``` |
||||
|
||||
## Configuration |
||||
|
||||
See [Commands File](topics/command-file.md) for creating a configuration file. |
||||
|
||||
## FAQs |
||||
|
||||
Have a question? `Just ask`_! |
||||
|
||||
.. _Just ask: https://develmaycare.com/contact/?product=Script%20Tease |
||||
|
After Width: | Height: | Size: 301 KiB |
After Width: | Height: | Size: 393 KiB |
After Width: | Height: | Size: 33 KiB |
After Width: | Height: | Size: 111 KiB |
After Width: | Height: | Size: 181 KiB |
@ -1,6 +1,6 @@ |
||||
# Steps File |
||||
# Command File |
||||
|
||||
A steps file contains the metadata about the commands to be generated. INI and YAML formats are supported. |
||||
A command file contains the metadata about the commands to be generated. INI and YAML formats are supported. |
||||
|
||||
In an INI file, each section is a command. With YAML, each top-level list item is a command. |
||||
|
@ -1,21 +0,0 @@ |
||||
# Getting Started |
||||
|
||||
## System Requirements |
||||
|
||||
Python 3.6 or greater is required. |
||||
|
||||
## Install |
||||
|
||||
To install: |
||||
|
||||
```bash |
||||
pip install python-scripttease; |
||||
``` |
||||
|
||||
## Configuration |
||||
|
||||
See [Steps File](topics/steps-file.md) for creating a configuration file. |
||||
|
||||
## FAQs |
||||
|
||||
**Does Script Tease execute commands?** No. Script Tease generates statements that may be [saved to a file for examination and execution](how-to/create-executable-script.md). Or a [custom implementation](how-to/use-with-commonkit.md) may be created to execute the generated statements. |
@ -1,119 +0,0 @@ |
||||
# PostgreSQL |
||||
|
||||
Summary: Work with Postgres databases. |
||||
|
||||
## Common Options |
||||
|
||||
- `host` (str): The host name. Default: `localhost` |
||||
- `password` (str): The password of the user executing the command. |
||||
- `port` (int): The TCP port. Default: `5432` |
||||
- `user` (str): The username of the user executing the command. Default: `postgres` |
||||
|
||||
## Automatic Conversion of Postgres Command Switches |
||||
|
||||
Options provided in the steps file are automatically converted to command line switches. For example: |
||||
|
||||
```ini |
||||
[create a soft backup of the database schema] |
||||
pgsql.dump: example_app |
||||
schema_only: yes |
||||
path: /tmp/example_app.sql |
||||
|
||||
``` |
||||
|
||||
`schema_only` becomes "--schema-only". |
||||
|
||||
## Available Commands |
||||
|
||||
### pgsql.create |
||||
|
||||
Create a database. Argument is the database name. |
||||
|
||||
- `owner` (str): The username that owns the database. |
||||
|
||||
```ini |
||||
[create the database] |
||||
pgsql.create: database_name |
||||
``` |
||||
|
||||
### pgsql.drop |
||||
|
||||
Drop a database. Argument is the database name. |
||||
|
||||
```ini |
||||
[drop the testing database] |
||||
pgsql.drop: testing_example_app |
||||
|
||||
``` |
||||
|
||||
### pgsql.dump |
||||
|
||||
Dump the database schema. Argument is the database name. |
||||
|
||||
- `path` (str): The path to the dump file. Default: `database_name.sql` |
||||
|
||||
```ini |
||||
[create a soft backup of the database] |
||||
pgsql.dump: example_app |
||||
column_inserts: yes |
||||
path: /tmp/example_app.sql |
||||
|
||||
``` |
||||
|
||||
### pgsql.exists |
||||
|
||||
Determine if a database exists. Argument is the database name. |
||||
|
||||
```ini |
||||
[determine if the database exists] |
||||
pgsql.exists: example_app |
||||
|
||||
``` |
||||
|
||||
### pgsql.grant |
||||
|
||||
Grant privileges to a user. Argument is the username. Database option is required. |
||||
|
||||
- `database` (str): The name of the database where the target object exists. |
||||
- `privileges` (str): The privileges to be granted. Default `ALL` (see [Postgres docs](https://www.postgresql.org/docs/current/sql-grant.html)) |
||||
- `schema` (str): The schema name to which the privileges apply. |
||||
- `table` (str): The table name to which privileges apply. |
||||
|
||||
!!! note |
||||
A schema name or table name is required. |
||||
|
||||
```ini |
||||
[grant select access to bob] |
||||
pgsql.grant: bob |
||||
database: example_app |
||||
privileges: select |
||||
schema: public |
||||
|
||||
``` |
||||
|
||||
### pgsql.user |
||||
|
||||
Create a user. Argument is the user name. |
||||
|
||||
- `password` (str): The user's password. |
||||
|
||||
```ini |
||||
[create a database user] |
||||
pgsql.user: username |
||||
``` |
||||
|
||||
Remove a user. |
||||
|
||||
```ini |
||||
[remove a database user] |
||||
pgsql.user: username |
||||
op: remove |
||||
``` |
||||
|
||||
Determine if a user exists. |
||||
|
||||
```ini |
||||
[determine if database user exists] |
||||
pgsql.user: username |
||||
op: exists |
||||
``` |
@ -1,264 +0,0 @@ |
||||
# POSIX |
||||
|
||||
Summary: Work with common POSIX-compliant commands.. |
||||
|
||||
## Available Commands |
||||
|
||||
### append |
||||
|
||||
Append content to a file. Argument is the file name. |
||||
|
||||
- `content` (str): The content to be appended. |
||||
|
||||
```ini |
||||
[add to the log file] |
||||
append: /path/to/file.log |
||||
content: This is a test. |
||||
``` |
||||
|
||||
### archive |
||||
|
||||
Create an archive (tarball). Argument is the target file or directory. |
||||
|
||||
- `absolute` (bool): Don't strip leading slashes from file names. Default `False` |
||||
- `exclude` (str): Exclude file name patterns. |
||||
- `file_name` (str): The name of the archive file. Default `archive.tgz` |
||||
- `strip` (int): Strip component paths to the given depth. |
||||
- `to_path` (str): The path to where the archive will be created. Default `.` |
||||
- `view` (bool): View the progress. Default `False` |
||||
|
||||
```ini |
||||
[create an archive of the site] |
||||
archive: /path/to/file_or_directory |
||||
file_name: testing.tgz |
||||
to: /tmp |
||||
|
||||
``` |
||||
|
||||
### certbot |
||||
|
||||
Alias: ssl |
||||
|
||||
Use Let's Encrypt (certbot) to acquire an SSL certificate. Argument is the domain name. |
||||
|
||||
- `email`: The email address for "agree tos". Default: `webmaster@domain_name` |
||||
- `webroot`: The webroot to use. Default: `/var/www/maint/www` |
||||
|
||||
```ini |
||||
[get an SSL cert] |
||||
ssl: example.app |
||||
email: webmaster@example.app |
||||
|
||||
``` |
||||
|
||||
### copy |
||||
|
||||
Copy a file or directory. First argument is the target file/directory. Second argument is the destination. |
||||
|
||||
- `overwrite` (bool): Overwrite an existing target. |
||||
- `recursive` (bool): Copy directories recursively. |
||||
|
||||
```ini |
||||
[copy a directory] |
||||
copy: /path/to/directory /path/to/new_directory |
||||
overwrite: yes |
||||
recursive: yes |
||||
|
||||
``` |
||||
|
||||
### dir |
||||
|
||||
Create a directory. Argument is the path. |
||||
|
||||
- `group` (str): Set the group to the given group name. |
||||
- `mode` (str): Set the mode on the path. |
||||
- `owner` (str): Set the owner to the given owner name. |
||||
- `recursive` (str): Create the full path even if intermediate directories do not exist. |
||||
|
||||
```ini |
||||
[create a directory] |
||||
dir: /path/to/directory |
||||
group: www-data |
||||
mode: 755 |
||||
owner: deploy |
||||
recursive: yes |
||||
|
||||
``` |
||||
|
||||
### extract |
||||
|
||||
Extract an archive (tarball). Argument is the path to the archive file. |
||||
|
||||
- `absolute` (bool): Don't strip leading slashes from file names. Default `False` |
||||
- `exclude` (str): Exclude file name patterns. |
||||
- `strip` (int): Strip component paths to the given depth. |
||||
- `to_path` (str): The path to where the archive will be created. Default `./` |
||||
- `view` (bool): View the progress. Default `False` |
||||
|
||||
```ini |
||||
[extract an archive] |
||||
extract: /path/to/archive.tgz |
||||
|
||||
``` |
||||
|
||||
### link |
||||
|
||||
Create a symlink. First argument is the source. |
||||
|
||||
- `force` (bool): Force creation of the link. |
||||
- `target` (str): The location of the link. Defaults to the current directory and the base name of the source. |
||||
|
||||
```ini |
||||
[create a symlink] |
||||
link: /path/to/project/releases/1.0 |
||||
cd: /path/to/project |
||||
force: yes |
||||
target: current |
||||
|
||||
``` |
||||
|
||||
### move |
||||
|
||||
Move a file or directory. First argument is the target. Second argument is the desitnation. |
||||
|
||||
```ini |
||||
[move a file] |
||||
move: /path/to/file.txt /new/path/to/file.txt |
||||
|
||||
``` |
||||
|
||||
### perms |
||||
|
||||
Set permissions on a file or directory. Argument is the path. |
||||
|
||||
- `group` (str): Set the group to the given group name. |
||||
- `mode` (str): Set the mode on the path. |
||||
- `owner` (str): Set the owner to the given owner name. |
||||
- `recursive` (bool): Apply permission recursively (directories only). |
||||
|
||||
```ini |
||||
[set permissions on the shared directory] |
||||
perms: /path/to/project/shared |
||||
group: www-data |
||||
mode: 775 |
||||
owner: deploy |
||||
recursive: yes |
||||
|
||||
``` |
||||
|
||||
### push |
||||
|
||||
Alias: rsync |
||||
|
||||
Push (rsync) a path to a remote server. First argument is the local path. Second argument is the remote path. |
||||
|
||||
- `delete` (bool): Delete existing files/directories. Default `False` |
||||
- `host` (str): The host name. Required. |
||||
- `key_file` (str): Use the given SSL (private) key. |
||||
- `links` (bool): Copy symlinks. Default `True |
||||
- `exclude` (str): Exclude patterns from the given (local) file. |
||||
- `port` (int): The TCP port on the host. Default: `22` |
||||
- `recursive` (bool): Operate recursively on directories. |
||||
- `user` (str): The username. |
||||
|
||||
```ini |
||||
[push the project to the server] |
||||
push: /path/to/project /path/on/server |
||||
key_file: ~/.ssh/example_app |
||||
host: example.app |
||||
user: deploy |
||||
|
||||
``` |
||||
|
||||
### remove |
||||
|
||||
Remove a file or directory. Argument is the path. |
||||
|
||||
- `force` (bool): Force the removal. Default `False` |
||||
- `recursive` (bool): Remove all directories in the path. Default `False` |
||||
|
||||
```ini |
||||
[remove a directory] |
||||
remove: /path/to/directory |
||||
force: yes |
||||
recusrive: yes |
||||
``` |
||||
|
||||
### replace |
||||
|
||||
Replace something in a file. First argument is the path. |
||||
|
||||
- `backup`: Backup file extension. Default `.b` |
||||
- `delimiiter`: The sed delimiter. Default: `/` |
||||
- `find`: The text to be found. Required. |
||||
- `sub`: The text to be replaced. Required. |
||||
|
||||
```ini |
||||
[replace text in a file] |
||||
replace: /path/to/file.txt |
||||
find: testing |
||||
sub: 123 |
||||
``` |
||||
|
||||
### scopy |
||||
|
||||
Copy a file to a remote server. First argument is the local file name. Second argument is the remote destination. |
||||
|
||||
- `key_file` (str): The private key file to use for the connection. |
||||
- `host` (str): The host name. Required. |
||||
- `port` (int): The TCP port. Default: `22` |
||||
- `user` (str): The username. Required. |
||||
|
||||
```ini |
||||
[copy a file to the server] |
||||
scopy: /path/to/local.txt path/to/remove.txt |
||||
host: example.app |
||||
user: deploy |
||||
|
||||
``` |
||||
|
||||
### sync |
||||
|
||||
Sync (rsync) local files and directories. First argument is the target. Second argument is the destination. |
||||
|
||||
- `delete` (bool): Delete existing files/directories. |
||||
- `links` (bool): Copy symlinks. |
||||
- `exclude` (str): Exclude patterns from the given (local) file. |
||||
- `recursive` (bool): Operate recursively on directories. |
||||
|
||||
```ini |
||||
[syncrhonize files on the local machine] |
||||
sync: /path/to/project /path/to/sync/directory |
||||
|
||||
``` |
||||
|
||||
### touch |
||||
|
||||
Touch a file, whether it exists or not. Argument is the path. |
||||
|
||||
```ini |
||||
[touch a file] |
||||
touch: /path/to/file.txt |
||||
``` |
||||
|
||||
### wait |
||||
|
||||
Wait for n number of seconds before continuing. Argument is the number of seconds. |
||||
|
||||
```ini |
||||
[wait just a minute] |
||||
wait: 60 |
||||
``` |
||||
|
||||
### write |
||||
|
||||
Write to a file. Argument is the path. |
||||
|
||||
- `content` (str): The content to write to the file. Replaces existing content. |
||||
|
||||
```ini |
||||
[replace an existing file] |
||||
write: /path/to/file.txt |
||||
content: This whole file has been replaced. |
||||
|
||||
``` |
@ -1,49 +0,0 @@ |
||||
# Python |
||||
|
||||
Summary: Work with Python. |
||||
|
||||
## Available Commands |
||||
|
||||
### pip |
||||
|
||||
Use the pip command. Argument is the package name. |
||||
|
||||
- `op` (str): The operation; `install` (the default) or `remove`. |
||||
- `upgrade` (bool): Upgrade the package. |
||||
- `venv` (str): The name of the virtual environment to use. |
||||
- `version` (int): The pip version to use. Default `3` |
||||
|
||||
```ini |
||||
[install django] |
||||
pip: django |
||||
cd: /path/to/project |
||||
venv: python |
||||
``` |
||||
|
||||
### pip_file |
||||
|
||||
Alias: pipf |
||||
|
||||
Install packages from a pip file. |
||||
|
||||
- `venv` (str): The name of the virtual environment to use. |
||||
- `version` (int): The pip version to use. Default `3` |
||||
|
||||
```ini |
||||
[install dependencies] |
||||
pip_file: deploy/packages/testing.pip |
||||
cd: path/to/project |
||||
venv: python |
||||
|
||||
``` |
||||
|
||||
### virtualenv |
||||
|
||||
Create a python virtual environment. Argument is the environment name. |
||||
|
||||
```ini |
||||
[create the virtual environment] |
||||
virtualenv: python |
||||
cd: /path/to/project |
||||
|
||||
``` |