diff --git a/wp-cli/_test.sh b/wp-cli/_test.sh new file mode 100755 index 0000000..cabd57d --- /dev/null +++ b/wp-cli/_test.sh @@ -0,0 +1,11 @@ + +#!/bin/bash + +packages_list=$(wp package list | sed -n '1!p' | awk '{print $1'}) + +# Si le package /wp-cli/admin-command est installé + +if [ -n "$(echo "$packages_list" | awk '$1 ~ /wp-cli\/admin-command/')" ]; then + echo "installed" + wp admin --path='../../Sites/wordpress' +fi diff --git a/wp-cli/cd.sh b/wp-cli/cd.sh new file mode 100755 index 0000000..2316440 --- /dev/null +++ b/wp-cli/cd.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +cd Downloads +ls + diff --git a/wp-cli/install_wp.sh b/wp-cli/install_wp.sh new file mode 100755 index 0000000..ae1ece5 --- /dev/null +++ b/wp-cli/install_wp.sh @@ -0,0 +1,173 @@ +#!/usr/bin/env bash + +# WordPress installer + +# ATTENTION: si wp-cli.local.yml est présent, wp l'utilise ! + +if [ "$1" == "--help" ]; then + echo -e "\033[93minstall_wp.sh\033[0m" + echo + echo "Installateur WordPress" + echo + echo "Requiert:" + echo " - wp-cli (https://wp-cli.org/)" + echo + echo "Attention:" + echo " - si wp-cli.local.yml est présent dans le répertoire d'installation (\$wordpress_path), wp-cli l'utilise !" + echo + echo "Configuration:" + echo -e " - \033[4m\$wordpress_path\033[0m est le chemin où sera installé WordPress" + echo -e " - \033[4m\$path\033[0m est le nom du répertoire d'installation (wordpress par défaut)" + echo -e " - \033[4m\$url\033[0m est l'adresse du site:" + echo " - \$url=http://localhost - WP sera installé à la racine du site." + echo " - \$url=http://localhost/wordpress - WP sera installé dans le dossier \$path" + echo + echo "USAGE: install_wp_yml" + echo + echo " --help display this help" + echo + exit 0 +fi + +# Paramètres: +#bdd +dbhost=localhost +dbuser=xxx +dbpass='xxx' +# +dbname='wordpress4' +dbprefix='wp4_' + +#wp-cli +path=wordpress +wordpress_path='/home/bruno/Sites' +url=http://localhost/wordpress +# Administrateur +title="My WordPress Blog" +admin_user=xxx +admin_password='xxx' +admin_email='xxx' +# Thèmes activé, plugins installés +default_theme=twentyfourteen +defaults_plugins='admin-post-navigation meow-lightbox wp-retina-2x-pro sola-newsletters' +# Version de WordPress +locale=fr_FR +version=4.8 +# extra_php is an array: array=("value1" "value2") +extra_php=("define( 'WP_DEBUG', true );" "define( 'WP_DEBUG_LOG', true );") +# Packages wp-cli installés +defaults_packages="wp-cli/admin-command trepmal/wp-revisions-cli" +# Ouvrir la page d'aministration +admin=true + +source pass.cfg + +# /Paramètres + + +cd $wordpress_path + +# Il y a déjà une installation de WordPress ? +exist=$(wp find . | sed -n '1!p' | awk '{print$1}') + +# Si oui, on la supprime +if [ -n "$exist" ]; then + + # /home/bruno/Sites/wordpress/wp-includes/version.php + + wp_exist="$(dirname $(dirname $exist))" + + wp_folder_name=$(echo "$exist" | awk -F "/" '{for (i=1;i<=NF;i++) if ($i=="wp-includes") print $(i-1)}') + + read -p $'\n\033[1;31mWordPress is already installed. Do you really want to erase it ? \033[39m(y/n)\033[0m' choice + case "$choice" in + y|Y|o ) cd "$wp_folder_name/" && wp db drop --yes && cd "$wordpress_path" && rm -rf "$wp_folder_name/" && echo "Deleting directory '$wordpress_path/$wp_folder_name'.";; + * ) echo "Ok, let's exit" && exit 0;; +# * ) echo "invalid";; + esac + +fi + +# On récupère la liste des packages installés +echo "Get WP-CLI packages already installed list..." +packages_list=$(wp package list | sed -n '1!p' | awk '{print $1'}) +#if [ $? != 0 ]; then echo "$packages_list"; fi + +if [ -n "$packages_list" ]; then echo "Info: Installed WP-CLI packages: $packages_list" | tr '\n' ' ' | sed '$s/ $/\n/' +else echo "Info: No package installed !" +fi + +# Télécharger WordPress: +echo "path: $path" + +dl=$(wp core download --path=$path --locale=$locale --version=$version) +#if [ $? != 0 ]; then echo "$dl"; fi + +# Créer le fichier de config (wp-config.php): +#$ wp config create --dbname=testdb --dbuser=wp --dbpass=yourpassword + + +# Avec Des options supplémentaires: +wp core config --path=$path --dbname=$dbname --dbuser=$dbuser --dbpass=$dbpass --dbhost=$dbhost --dbprefix=$dbprefix --extra-php < SELECT @@character_set_database, @@collation_database; + +# Installer WordPress: +# Si sh: 1: /usr/sbin/sendmail: not found => ajouter --skip-email + +co=$(wp core install --path=$path --url=$url --title='$title' --admin_user=$admin_user --admin_password=$admin_password --admin_email=$admin_email --skip-email) +#if [ $? != 0 ]; then echo "$co"; fi + +# Changement de la structure des liens pour ne conserver que le nom de l'article: +rw=$(wp rewrite structure --path=$path '/%postname%') +#if [ $? != 0 ]; then echo "$rw"; fi + +# Installer un thème: +#Warning: twentyseventeen: Theme already installed. + +th=$(wp theme install --path=$path $default_theme) +#if [ $? != 0 ]; then echo "$th"; fi + +# Activer le thème: +#Warning: The 'Twenty Seventeen' theme is already active. + +ac=$(wp theme activate --path=$path $default_theme) +#if [ $? != 0 ]; then echo "$ac"; fi + +# Installer et activer les plugins: +#Warning: Couldn't find 'wp-retina-2x-pro' in the WordPress.org plugin directory. +#Warning: The 'wp-retina-2x-pro' plugin could not be found. + +pl=$(wp plugin install --path=$path $defaults_plugins --activate) +#if [ $? != 0 ]; then echo -e "\033[31mErrors log:\033[0m" && echo "$pl\n"; fi + +# Installer les packages: + +for i in $defaults_packages +do + if [[ "$packages_list" != *"$i"* ]]; then + pa=$(wp package install "$i") + #if [ $? != 0 ]; then echo "$pa"; fi + else + echo "Info: $i already installed !" + fi +done + +# Ouvrir le tableau de bord dans un navigateur: +# Si le package /wp-cli/admin-command est installé, on ouvre la page d'administration + +if [ "$admin" = true ]; then + echo -e "\n\033[1mOpen wp-admin/ page in browser...\033[0m" + wp admin --path=$path +fi + + diff --git a/wp-cli/install_wp_yml.sh b/wp-cli/install_wp_yml.sh new file mode 100755 index 0000000..033f9d3 --- /dev/null +++ b/wp-cli/install_wp_yml.sh @@ -0,0 +1,95 @@ +#!/usr/bin/env bash + +# WordPress installer (wp-cli.local.yml) + +if [ "$1" == "--help" ]; then + echo -e "\033[93minstall_wp_yml.sh\033[0m" + echo + echo "Installateur WordPress" + echo + echo "Requiert:" + echo " - wp-cli (https://wp-cli.org/)" + echo " - wp-cli.local.yml DOIT être présent dans \$wordpress_path" + echo + echo "Configuration:" + echo -e " - \033[4m\$wordpress_path\033[0m est le dossier où sera installé WordPress" + echo -e " - \033[4m\$wp_config_yml\033[0m est le nom du fichier d'installation WordPress. Il sera copié dans \$wordpress_path" + echo + echo "USAGE: install_wp_yml" + echo + echo " --help display this help" + echo + exit 0 +fi + + +# *** Variables à configurer / Configure this variables ***: + +wordpress_path="/home/bruno/Sites/" +wp_config_yml="wp_mint.local.yml" + +# *** -----------------------*** + +echo + +# On copie le fichier de configuration sur le serveur +yml_file="$(pwd)/$wp_config_yml" +#[ ! -f "$yml_file" ] || (echo "No configuration file ("$wp_config_yml") found! Let's exit :-(" && exit 0) + +if [ ! -f "$yml_file" ]; then + echo "No configuration file ("$wp_config_yml") found! Let's exit :-(" + exit 0 +else + echo "Configuration file "$wp_config_yml" found! Let's copy it to "$wordpress_path"" + cp "$(pwd)/$wp_config_yml" "$wordpress_path/wp-cli.local.yml" +fi + +cd $wordpress_path + +echo -e "\n\033[1mWordPress installation\033[0m" + +# On récupère la liste des packages installés +packages_list=$(wp package list | sed -n '1!p' | awk '{print $1'}) + +# Il y a déjà une installation de WordPress ? +exist=$(wp find . | sed -n '1!p' | awk '{print$1}') + +# Si oui, on la supprime +if [ -n "$exist" ]; then + + # /home/bruno/Sites/wordpress/wp-includes/version.php + + wp_exist="$(dirname $(dirname $exist))" + + wp_folder_name=$(echo "$exist" | awk -F "/" '{for (i=1;i<=NF;i++) if ($i=="wp-includes") print $(i-1)}') + + read -p $'\n\033[1;31mWordPress is already installed. Do you really want to erase it ? \033[39m(y/n)\033[0m' choice + case "$choice" in + y|Y|o ) cd "$wp_folder_name/" && wp db drop --yes && cd "$wordpress_path" && rm -rf "$wp_folder_name/" && echo "Deleting directory '$wordpress_path/$wp_folder_name'.";; + * ) echo "Ok, let's exit" && exit 0;; +# * ) echo "invalid";; + esac + +fi + +echo +wp core download +wp core config +wp db create +wp core install --skip-email +wp theme install +wp theme activate +wp plugin install + +# Installer un plug-in depuis une archive: +#$ wp plugin install https://d1qas1txbec8n.cloudfront.net/wp-content/uploads/2015/06/23073607/myplugin.zip + +# Si le package /wp-cli/admin-command est installé, on ouvre la page d'administration +if [ -n "$(echo "$packages_list" | awk '$1 ~ /wp-cli\/admin-command/')" ]; then + wp admin +else + wp package install wp-cli/admin-command + echo "" + wp admin +fi + diff --git a/wp-cli/man.snap.txt b/wp-cli/man.snap.txt new file mode 100644 index 0000000..a70432c --- /dev/null +++ b/wp-cli/man.snap.txt @@ -0,0 +1,653 @@ +snap(1) General Commands Manual snap(1) + +NAME + snap - Tool to interact with snaps + +SYNOPSIS + snap [OPTIONS] + +DESCRIPTION + Install, configure, refresh and remove snap packages. Snaps are enabling secure distribution of the latest apps and utilities for cloud, servers, desktops and the internet of things. + + This is the CLI for snapd, a background service that takes care of snaps on the system. Start with 'snap list' to see installed snaps. + +OPTIONS + Application Options +COMMANDS + abort + Abort a pending change + + The abort command attempts to abort a change that still has pending tasks. + + Usage: snap [OPTIONS] abort [abort-OPTIONS] + + --last Select last change of given type (install, refresh, remove, try, auto-refresh etc.) + + ack + Add an assertion to the system + + The ack command tries to add an assertion to the system assertion database. + + The assertion may also be a newer revision of a pre-existing assertion that it will replace. + + To succeed the assertion must be valid, its signature verified with a known public key and the assertion consistent with and its prerequisite in the database. + + alias + Set up a manual alias + + The alias command aliases the given snap application to the given alias. + + Once this manual alias is setup the respective application command can be invoked just using the alias. + + Usage: snap [OPTIONS] alias [alias-OPTIONS] + + --no-wait + Do not wait for the operation to finish but just print the change id. + + aliases + List aliases in the system + + The aliases command lists all aliases available in the system and their status. + + $ snap aliases + + Lists only the aliases defined by the specified snap. + + An alias noted as undefined means it was explicitly enabled or disabled but is not defined in the current revision of the snap, possibly temporarily (e.g. because of a revert). This can cleared + with 'snap alias --reset'. + + buy + Buy a snap + + The buy command buys a snap from the store. + + changes + List system changes + + The changes command displays a summary of system changes performed recently. + + Usage: snap [OPTIONS] changes [changes-OPTIONS] + + --abs-time + Display absolute times (in RFC 3339 format). Otherwise, display relative times up to 60 days, then YYYY-MM-DD. + + connect + Connect a plug to a slot + + The connect command connects a plug to a slot. It may be called in the following ways: + + $ snap connect : : + + Connects the provided plug to the given slot. + + $ snap connect : + + Connects the specific plug to the only slot in the provided snap that matches the connected interface. If more than one potential slot exists, the command fails. + + $ snap connect : + + Connects the provided plug to the slot in the core snap with a name matching the plug name. + + Usage: snap [OPTIONS] connect [connect-OPTIONS] + + --no-wait + Do not wait for the operation to finish but just print the change id. + + disable + Disable a snap in the system + + The disable command disables a snap. The binaries and services of the snap will no longer be available, but all the data is still available and the snap can easily be enabled again. + + Usage: snap [OPTIONS] disable [disable-OPTIONS] + + --no-wait + Do not wait for the operation to finish but just print the change id. + + disconnect + Disconnect a plug from a slot + + The disconnect command disconnects a plug from a slot. It may be called in the following ways: + + $ snap disconnect : : + + Disconnects the specific plug from the specific slot. + + $ snap disconnect : + + Disconnects everything from the provided plug or slot. The snap name may be omitted for the core snap. + + Usage: snap [OPTIONS] disconnect [disconnect-OPTIONS] + + --no-wait + Do not wait for the operation to finish but just print the change id. + + download + Download the given snap + + The download command downloads the given snap and its supporting assertions to the current directory with .snap and .assert file extensions, respectively. + + Usage: snap [OPTIONS] download [download-OPTIONS] + + --channel + Use this channel instead of stable + + --edge Install from the edge channel + + --beta Install from the beta channel + + --candidate + Install from the candidate channel + + --stable + Install from the stable channel + + --revision + Download the given revision of a snap, to which you must have developer access + + enable + Enable a snap in the system + + The enable command enables a snap that was previously disabled. + + Usage: snap [OPTIONS] enable [enable-OPTIONS] + + --no-wait + Do not wait for the operation to finish but just print the change id. + + find + Find packages to install + + The find command queries the store for available packages in the stable channel. + + With the --private flag, which requires the user to be logged-in to the store (see 'snap help login'), it instead searches for private snaps that the user has developer access to, either directly + or through the store's collaboration feature. + + Usage: snap [OPTIONS] find [find-OPTIONS] + + Aliases: search + + --private + Search private snaps + + --narrow + Only search for snaps in “stable” + + --section [="show-all-sections-please"] + Restrict the search to a given section + + get + Print configuration options + + The get command prints configuration options for the provided snap. + + $ snap get snap-name username + frank + + If multiple option names are provided, a document is returned: + + $ snap get snap-name username password + { + "username": "frank", + "password": "..." + } + + Nested values may be retrieved via a dotted path: + + $ snap get snap-name author.name + frank + + Usage: snap [OPTIONS] get [get-OPTIONS] + + -t Strict typing with nulls and quoted strings + + -d Always return document, even with single key + + -l Always return list, even with single key + + help + Show help about a command + + The help command displays information about snap commands. + + Usage: snap [OPTIONS] help [help-OPTIONS] + + info + Show detailed information about snaps + + The info command shows detailed information about snaps. + + The snaps can be specified by name or by path; names are looked for both in the store and in the installed snaps; paths can refer to a .snap file, or to a directory that contains an + unpacked snap suitable for 'snap try' (an example of this would be the 'prime' directory snapcraft produces). + + Usage: snap [OPTIONS] info [info-OPTIONS] + + --abs-time + Display absolute times (in RFC 3339 format). Otherwise, display relative times up to 60 days, then YYYY-MM-DD. + + --verbose + Include more details on the snap (expanded notes, base, etc.) + + install + Install a snap to the system + + The install command installs the named snaps in the system. + + With no further options, the snaps are installed tracking the stable channel, with strict security confinement. + + Revision choice via the --revision override requires the the user to have developer access to the snap, either directly or through the store's collaboration feature, and to be logged in (see + 'snap help login'). + + Note a later refresh will typically undo a revision override, taking the snap back to the current revision of the channel it's tracking. + + Usage: snap [OPTIONS] install [install-OPTIONS] + + --no-wait + Do not wait for the operation to finish but just print the change id. + + --channel + Use this channel instead of stable + + --edge Install from the edge channel + + --beta Install from the beta channel + + --candidate + Install from the candidate channel + + --stable + Install from the stable channel + + --devmode + Put snap in development mode and disable security confinement + + --jailmode + Put snap in enforced confinement mode + + --classic + Put snap in classic mode and disable security confinement + + --revision + Install the given revision of a snap, to which you must have developer access + + --dangerous + Install the given snap file even if there are no pre-acknowledged signatures for it, meaning it was not verified and could be dangerous (--devmode implies this) + + --unaliased + Install the given snap without enabling its automatic aliases + + interface + List snap interfaces + + The interface command shows details of snap interfaces. + + If no interface name is provided, a list of interface names with at least one connection is shown, or a list of all interfaces if --all is provided. + + Usage: snap [OPTIONS] interface [interface-OPTIONS] + + --attrs + Show interface attributes + + --all Include unused interfaces + + interfaces + List interfaces in the system + + The interfaces command lists interfaces available in the system. + + By default all slots and plugs, used and offered by all snaps, are displayed. + + $ snap interfaces : + + Lists only the specified slot or plug. + + $ snap interfaces + + Lists the slots offered and plugs used by the specified snap. + + $ snap interfaces -i= [] + + Filters the complete output so only plugs and/or slots matching the provided details are listed. + + Usage: snap [OPTIONS] interfaces [interfaces-OPTIONS] + + -i Constrain listing to specific interfaces + + known + Show known assertions of the provided type + + The known command shows known assertions of the provided type. If header=value pairs are provided after the assertion type, the assertions shown must also have the specified headers matching the + provided values. + + Usage: snap [OPTIONS] known [known-OPTIONS] + + --remote + + list + List installed snaps + + The list command displays a summary of snaps installed in the current system. + + Usage: snap [OPTIONS] list [list-OPTIONS] + + --all Show all revisions + + login + Authenticate to snapd and the store + + The login command authenticates the user to snapd and the snap store, and saves credentials into the ~/.snap/auth.json file. Further communication with snapd will then be made using those creden‐ + tials. + + It's not necessary to log in to interact with snapd. Doing so, however, enables purchasing of snaps using 'snap buy', as well as some some developer-oriented features as detailed in the help for + the find, install and refresh commands. + + An account can be set up at https://login.ubuntu.com + + logout + Log out of snapd and the store + + The logout command logs the current user out of snapd and the store. + + logs + Retrieve logs of services + + The logs command fetches logs of the given services and displays them in chronological order. + + Usage: snap [OPTIONS] logs [logs-OPTIONS] + + -n + Show only the given number of lines, or 'all'. + + -f Wait for new lines and print them as they come in. + + pack + Pack the given directory as a snap + + The pack command packs the given snap-dir as a snap and writes the result to target-dir. If target-dir is omitted, the result is written to current directory. If both source-dir and target-dir + are omitted, the pack command packs the current directory. + + When used with --check-skeleton, pack only checks whether snap-dir contains valid snap metadata and raises an error otherwise. Application commands listed in snap metadata file, but appearing + with incorrect permission bits result in an error. Commands that are missing from snap-dir are listed in diagnostic messages. + + Usage: snap [OPTIONS] pack [pack-OPTIONS] + + --check-skeleton + Validate snap-dir metadata only + + prefer + Prefer aliases from a snap and disable conflicts + + The prefer command enables all aliases of the given snap in preference to conflicting aliases of other snaps whose aliases will be disabled (or removed, for manual ones). + + Usage: snap [OPTIONS] prefer [prefer-OPTIONS] + + --no-wait + Do not wait for the operation to finish but just print the change id. + + refresh + Refresh a snap in the system + + The refresh command updates the specified snaps, or all snaps in the system if none are specified. + + With no further options, the snaps are refreshed to the current revision of the channel they're tracking, preserving their confinement options. + + Revision choice via the --revision override requires the the user to have developer access to the snap, either directly or through the store's collaboration feature, and to be logged in (see + 'snap help login'). + + Note a later refresh will typically undo a revision override. + + Usage: snap [OPTIONS] refresh [refresh-OPTIONS] + + --abs-time + Display absolute times (in RFC 3339 format). Otherwise, display relative times up to 60 days, then YYYY-MM-DD. + + --no-wait + Do not wait for the operation to finish but just print the change id. + + --channel + Use this channel instead of stable + + --edge Install from the edge channel + + --beta Install from the beta channel + + --candidate + Install from the candidate channel + + --stable + Install from the stable channel + + --devmode + Put snap in development mode and disable security confinement + + --jailmode + Put snap in enforced confinement mode + + --classic + Put snap in classic mode and disable security confinement + + --amend + Allow refresh attempt on snap unknown to the store + + --revision + Refresh to the given revision, to which you must have developer access + + --list Show available snaps for refresh but do not perform a refresh + + --time Show auto refresh information but do not perform a refresh + + --ignore-validation + Ignore validation by other snaps blocking the refresh + + remove + Remove a snap from the system + + The remove command removes the named snap from the system. + + By default all the snap revisions are removed, including their data and the common data directory. When a --revision option is passed only the specified revision is removed. + + Usage: snap [OPTIONS] remove [remove-OPTIONS] + + --no-wait + Do not wait for the operation to finish but just print the change id. + + --revision + Remove only the given revision + + restart + Restart services + + The restart command restarts the given services. + + If the --reload option is given, for each service whose app has a reload command, a reload is performed instead of a restart. + + Usage: snap [OPTIONS] restart [restart-OPTIONS] + + --no-wait + Do not wait for the operation to finish but just print the change id. + + --reload + If the service has a reload command, use it instead of restarting. + + revert + Reverts the given snap to the previous state + + The revert command reverts the given snap to its state before the latest refresh. This will reactivate the previous snap revision, and will use the original data that was associated with that + revision, discarding any data changes that were done by the latest revision. As an exception, data which the snap explicitly chooses to share across revisions is not touched by the revert + process. + + Usage: snap [OPTIONS] revert [revert-OPTIONS] + + --no-wait + Do not wait for the operation to finish but just print the change id. + + --devmode + Put snap in development mode and disable security confinement + + --jailmode + Put snap in enforced confinement mode + + --classic + Put snap in classic mode and disable security confinement + + --revision + Revert to the given revision + + run + Run the given snap command + + The run command executes the given snap command with the right confinement and environment. + + Usage: snap [OPTIONS] run [run-OPTIONS] + + --shell + Run a shell instead of the command (useful for debugging) + + --strace [="with-strace"] + Run the command under strace (useful for debugging). Extra strace options can be specified as well here. Pass --raw to strace early snap helpers. + + --gdb Run the command with gdb + + services + Query the status of services + + The services command lists information about the services specified, or about the services in all currently installed snaps. + + set + Change configuration options + + The set command changes the provided configuration options as requested. + + $ snap set snap-name username=frank password=$PASSWORD + + All configuration changes are persisted at once, and only after the snap's configuration hook returns successfully. + + Nested values may be modified via a dotted path: + + $ snap set author.name=frank + + Usage: snap [OPTIONS] set [set-OPTIONS] + + --no-wait + Do not wait for the operation to finish but just print the change id. + + start + Start services + + The start command starts, and optionally enables, the given services. + + Usage: snap [OPTIONS] start [start-OPTIONS] + + --no-wait + Do not wait for the operation to finish but just print the change id. + + --enable + As well as starting the service now, arrange for it to be started on boot. + + stop + Stop services + + The stop command stops, and optionally disables, the given services. + + Usage: snap [OPTIONS] stop [stop-OPTIONS] + + --no-wait + Do not wait for the operation to finish but just print the change id. + + --disable + As well as stopping the service now, arrange for it to no longer be started on boot. + + switch + Switches snap to a different channel + + The switch command switches the given snap to a different channel without doing a refresh. + + Usage: snap [OPTIONS] switch [switch-OPTIONS] + + --no-wait + Do not wait for the operation to finish but just print the change id. + + --channel + Use this channel instead of stable + + --edge Install from the edge channel + + --beta Install from the beta channel + + --candidate + Install from the candidate channel + + --stable + Install from the stable channel + + tasks + List a change's tasks + + The tasks command displays a summary of tasks associated with an individual change. + + Usage: snap [OPTIONS] tasks [tasks-OPTIONS] + + Aliases: change + + --abs-time + Display absolute times (in RFC 3339 format). Otherwise, display relative times up to 60 days, then YYYY-MM-DD. + + --last Select last change of given type (install, refresh, remove, try, auto-refresh etc.) + + try + Test a snap in the system + + The try command installs an unpacked snap into the system for testing purposes. The unpacked snap content continues to be used even after installation, so non-metadata changes there go live + instantly. Metadata changes such as those performed in snap.yaml will require reinstallation to go live. + + If snap-dir argument is omitted, the try command will attempt to infer it if either snapcraft.yaml file and prime directory or meta/snap.yaml file can be found relative to current working direc‐ + tory. + + Usage: snap [OPTIONS] try [try-OPTIONS] + + --no-wait + Do not wait for the operation to finish but just print the change id. + + --devmode + Put snap in development mode and disable security confinement + + --jailmode + Put snap in enforced confinement mode + + --classic + Put snap in classic mode and disable security confinement + + unalias + Unalias a manual alias or an entire snap + + The unalias command removes a single alias if the provided argument is a manual alias, or disables all aliases of a snap, including manual ones, if the argument is a snap name. + + Usage: snap [OPTIONS] unalias [unalias-OPTIONS] + + --no-wait + Do not wait for the operation to finish but just print the change id. + + version + Show version details + + The version command displays the versions of the running client, server, and operating system. + + wait + Wait for configuration + + The wait command waits until a configration becomes true. + + watch + Watch a change in progress + + The watch command waits for the given change-id to finish and shows progress (if available). + + Usage: snap [OPTIONS] watch [watch-OPTIONS] + + --last Select last change of given type (install, refresh, remove, try, auto-refresh etc.) + + whoami + Print the email the user is logged in with + + The whoami command prints the email the user is logged in with. + + 19 July 2018 snap(1) diff --git a/wp-cli/pass.cfg b/wp-cli/pass.cfg new file mode 100644 index 0000000..f3feeef --- /dev/null +++ b/wp-cli/pass.cfg @@ -0,0 +1,14 @@ +# --bdd-- +# -dsm916 +#dbuser=root +#dbpass='qUtjnFdebz24N5Xy' +# -mint +dbuser=admin +dbpass='dt7ek7wA3' + +# --wp-- +admin_user=bruno +admin_password='9?RmZ7ykU3AF' +admin_email='bruno@clicclac.info' + + diff --git a/wp-cli/update_wp.sh b/wp-cli/update_wp.sh new file mode 100755 index 0000000..2227699 --- /dev/null +++ b/wp-cli/update_wp.sh @@ -0,0 +1,217 @@ +#!/usr/bin/env bash + +if [ "$1" == "--help" ]; then + echo -e "\033[93mupdate_wp.sh\033[0m" + echo + echo "Mise à jour et maintenance de WordPress" + echo + echo "Requiert:" + echo " - wp-cli (https://wp-cli.org/)" + echo + echo "Configuration:" + echo -e " - \033[4m\$path\033[0m est le nom du répertoire d'installation (wordpress par défaut)" + echo -e " - \033[4m\$wordpress_path\033[0m est le chemin où est installé WordPress" + echo -e " - \033[4m\$maint\033[0m : mettre sur \033[4mfalse\033[0m pour ne pas exécuter les opérations de maintenance (idem pour toutes les autres options)" + echo + echo "USAGE: update_wp" + echo + echo " --help display this help" + echo + exit 0 +fi + +# nom du répertoire d'installation +path=wordpress +# chemin où est installé WordPress +wordpress_path="/home/bruno/Sites/" + +# Maintenance +maint=true + + +# Nombre de révisions à conserver: +# Package trepmal/wp-revisions-cli requis ! +revisions=3 +# Effacer Pingback et Trackback +back=true +# Effacer les spams +removespam=true +# Effacer les révisions +rev=true +# Vider la corbeille +emptytrash=true +# Sauvegarde de la base +backup=true +# Maintenance de la base (optimize & repair) +database=false +# Effacer les transients expirés +transient=true +# Ouvrir la page d'aministration +admin=true + + +cd $wordpress_path + + +siteurl=$(wp option get siteurl --quiet --path=$path) +blogname=$(wp option get blogname --path=$path) +admin_email=$(wp option get admin_email --path=$path) +echo -e "\n\033[1mMise-à-jour et maintenance du site $blogname\033[0m" +echo "$siteurl" +echo "Pour toutes questions et problèmes, contacter l'administrateur $admin_email" + + +echo -e "\n\033[1;31mUpdates...\033[0m" + +echo -e "\n\033[1mCore update...\033[0m" + +# Vérifier si des MAJ sont disponibles ? +wp core check-update --path=$path + +echo -e "\n" + +# Mettre à jour WordPress: +wp core update --path=$path + +# Mettre à jour la bdd: +wp core update-db --path=$path + + +echo -e "\n\033[1mPlugins update...\033[0m" + +# Vérifier si des MAJ de plugins sont disponibles ? +wp plugin update --all --dry-run --path=$path + +echo -e "\n" + +# Mettre à jour tous les plugins: +wp plugin update --all --path=$path + + +echo -e "\n\033[1mThemes update...\033[0m" + +# Vérifier si des MAJ de themes sont disponibles ? +wp theme update --all --dry-run --path=$path + +echo -e "\n" + +# Mettre à jour tous les themes: +wp theme update --all --path=$path + + +echo -e "\n\033[1mLanguage update...\033[0m" + +# Mettre à jour les traductions de WordPress: +wp language core update --path=$path + +# Mettre à jour les traductions de tous les plugins: +wp language plugin update --all --path=$path + +# Mettre à jour les traductions de tous les themes: +wp language theme update --all --path=$path + +if [ "$maint" = true ]; then + echo -e "\n" + echo -e "\n\033[1;31mMaintenance...\033[0m" + + #On récupère la liste des packages installés + packages_list=$(wp package list | sed -n '1!p' | awk '{print $1'}) + + + if [ "$transient" = true ]; then + #echo -e "\n\033[1mSupprimer les transients expirés...\033[0m" + echo -e "\n\033[1mRemove expired transients...\033[0m" + + wp transient delete --expired --path=$path + fi + + if [ "$database" = true ]; then + #echo -e "\n\033[1mMaintenance bdd...\033[0m" + echo -e "\n\033[1mDatabase maintenance...\033[0m" + + wp db optimize --quiet --path=$path + + #wp db repair --quiet --path=$path + fi + + if [ "$backup" = true ]; then + #echo -e "\n\033[1mSauvegarde bdd...\033[0m" + echo -e "\n\033[1mDatabase backup...\033[0m" + + DATE=`date +%Y-%m-%d_%H:%M:%S` + file="wp-$blogname-$DATE.sql" + + wp db export "$file" --add-drop-table --path=$path + fi + + if [ "$removespam" = true ]; then + #echo -e "\n\033[1mEffacer le SPAM...\033[0m" + echo -e "\n\033[1mRemove spam comments...\033[0m" + + spam=$(wp comment list --status=spam --format=ids --path=$path) + if [ -n "$spam" ]; then + wp comment delete "$spam" --path=$path + else + echo "No SPAM" + fi + fi + + if [ "$emptytrash" = true ]; then + #echo -e "\n\033[1mEffacer les commentaires supprimés et post supprimés...\033[0m" + echo -e "\n\033[1mRemove comments in trash and comment from deleted posts...\033[0m" + + trashed=$(wp comment list --status=trash,post-trashed --format=ids --path=$path) + if [ -n "$trashed" ]; then + wp comment delete "$trashed" --path=$path + else + echo "No trashed post" + fi + fi + + #if [ "$rev" = true ]; then + if [[ -n "$(echo "$packages_list" | awk '$1 ~ /trepmal\/wp-revisions-cli/')" ]] && [[ "$rev" = true ]]; then + #echo -e "\n\033[1mGarder seulement $revisions révisions...\033[0m" + echo -e "\n\033[1mKeep only $revisions revisions...\033[0m" + wp revisions clean $revisions --path=$path + + elif [ "$rev" = true ]; then + wp package install trepmal/wp-revisions-cli + + echo -e "\n\033[1mKeep only $revisions revisions...\033[0m" + + wp revisions clean $revisions --path=$path + fi + + if [ "$back" = true ]; then + #echo -e "\n\033[1mListe des trackback...\033[0m" + echo -e "\n\033[1mTrackback list...\033[0m" + + trackback=$(wp comment list --type=trackback --format=ids --path=$path) + echo "$trackback" + + #echo -e "\n\033[1mListe des pingback...\033[0m" + echo -e "\n\033[1mPingback list...\033[0m" + + pingback=$(wp comment list --type=pingback --format=ids --path=$path) + echo "$pingback" + fi + + + # Ouvrir le tableau de bord dans un navigateur: + # Nécéssite le paquet admin-command (sera installé si nécessaire) + + if [[ -n "$(echo "$packages_list" | awk '$1 ~ /wp-cli\/admin-command/')" ]] && [[ "$admin" = true ]]; then + echo -e "\n\033[1mOpen wp-admin/ page in browser...\033[0m" + wp admin --path=$path + elif [ "$admin" = true ]; then + wp package install wp-cli/admin-command + echo "" + echo -e "\n\033[1mOpen wp-admin/ page in browser...\033[0m" + wp admin --path=$path + fi + + +fi + +echo -e "\n" + diff --git a/wp-cli/wp-cli.local.yml b/wp-cli/wp-cli.local.yml new file mode 100644 index 0000000..cc6c04b --- /dev/null +++ b/wp-cli/wp-cli.local.yml @@ -0,0 +1,48 @@ +path: wordpress +url: http://localhost/wordpress +core skip-plugins: + - hello-dolly +core skip-themes: + - twentyfourteen + - twentythirteen +core download: + locale: fr_FR + version: 4.8 +core config: + dbhost: localhost + dbname: wordpress4 + dbuser: admin + dbpass: dt7ek7wA3 + extra-php: | + define( 'WP_DEBUG', true ); + define( 'WP_DEBUG_LOG', true ); + define( 'WP_POST_REVISIONS', 3 ); +core install: + title: My WordPress Blog + admin_user: bruno + admin_password: 9?RmZ7ykU3AF + admin_email: bruno@clicclac.info +theme install: + - twentyfifteen +theme activate: + - twentyfifteen +plugin install: + - wordpress-seo + - admin-post-navigation + - meow-lightbox +# - gutemberg +# - jetpack + - jquery-updater + - sola-newsletters + - link-manager + - wp-super-cache +# - wp-print +# - wp-retina-2x-pro +# - subscribe-to-comments-reloaded +# - google-sitemap-generator + - akismet + + + + + diff --git a/wp-cli/wp_mint.local.yml b/wp-cli/wp_mint.local.yml new file mode 100644 index 0000000..dcb958e --- /dev/null +++ b/wp-cli/wp_mint.local.yml @@ -0,0 +1,48 @@ +path: wordpress +url: http://localhost/wordpress +core skip-plugins: + - hello-dolly +core skip-themes: + - twentyfourteen + - twentythirteen +core download: + locale: fr_FR + version: 4.8 +core config: + dbhost: localhost + dbname: wordpress4 + dbuser: admin + dbpass: dt7ek7wA3 + extra-php: + define( 'WP_DEBUG', true ); + define( 'WP_DEBUG_LOG', true ); + define( 'WP_POST_REVISIONS', 3 ); +core install: + title: My WordPress Blog + admin_user: bruno + admin_password: 9?RmZ7ykU3AF + admin_email: bruno@clicclac.info +theme install: + - twentyfifteen +theme activate: + - twentyfifteen +plugin install: + - wordpress-seo + - admin-post-navigation +## - meow-lightbox +# - gutemberg +# - jetpack + - jquery-updater +## - sola-newsletters + - link-manager +## - wp-super-cache +# - wp-print +# - wp-retina-2x-pro +# - subscribe-to-comments-reloaded +# - google-sitemap-generator +## - akismet + + + + +