-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add propagating verbose to external subcommands(#61) * Add propagating verbose to external subcommands(#61) * Add propagating verbose to external subcommands(#61) * enhanced create and add for wiki farm * added add and remove wiki in the Canasta container feature * updated farmsettings.go * cleaned the code * structure 0.1 * structure 0.2 * midterm version * Add documentation * Add documentation * test version * Update with HTTPS * Canasta-CLI 2.0 adding wiki farm support
- Loading branch information
Showing
30 changed files
with
1,411 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
*.dll | ||
*.so | ||
*.dylib | ||
*.yaml | ||
|
||
# Test binary, built with `go test -c` | ||
*.test | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
// If not running MediaWiki, exit | ||
if ( !defined( 'MEDIAWIKI' ) ) { | ||
exit; | ||
} | ||
#$wgServer = "http://localhost"; | ||
#$wgSitename = ; | ||
#$wgMetaNamespace = ; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,83 @@ | ||
# Canasta: Command Line Interface Tool for Canasta | ||
This is the official Command Line Interface tool for the Canasta. | ||
# Canasta CLI - Recent Enhancements & New Commands for wiki farm support | ||
|
||
We're excited to introduce a series of enhancements and new commands to the Canasta CLI. These changes aim to provide users with more flexibility and power in managing their MediaWiki instances and wiki farms. | ||
|
||
## Table of Contents | ||
- [Installation](#installation) | ||
- [Enhancements](#enhancements) | ||
- [create](#create) | ||
- [extension](#extension) | ||
- [skin](#skin) | ||
- [New Commands](#new-commands) | ||
- [add](#add) | ||
- [remove](#remove) | ||
|
||
|
||
## Enhancements | ||
|
||
### create | ||
**Description:** Creates a Canasta installation. Enhanced to support wiki farm setup with the `-f` flag. | ||
|
||
**Usage:** | ||
sudo go run canasta.go create [flags] | ||
- `-p, --path`: Canasta directory. | ||
- `-o, --orchestrator`: Orchestrator to use for installation (default: "docker-compose"). | ||
- `-i, --id`: Canasta instance ID. | ||
- `-w, --wiki`: Name of the wiki. | ||
- `-n, --domain-name`: Domain name (default: "localhost"). | ||
- `-a, --WikiSysop`: Initial wiki admin username. | ||
- `-s, --password`: Initial wiki admin password. | ||
- `-f, --yamlfile`: Initial wiki yaml file for wiki farm setup. | ||
- `-k, --keep-config`: Keep the config files on installation failure. | ||
|
||
**YAML Format for Wiki Farm:** | ||
To create a wiki farm, you need to provide a YAML file with the following format: | ||
```yaml | ||
wikis: | ||
- id: [WIKI_ID] # Example: "mywiki1" | ||
url: [WIKI_URL] # Example: "mywiki1.example.com" | ||
``` | ||
sudo go run canasta.go create -f [yamlfile] # Example: "wikis.yaml | ||
### extension | ||
**Description:** Manage Canasta extensions. Enhanced to target a specific wiki within the farm using the `-w` flag. | ||
|
||
**Subcommands:** | ||
- `list`: Lists all the installed Canasta extensions. | ||
- `enable`: Enables specified extensions. | ||
- `disable`: Disables specified extensions. | ||
|
||
**Usage:** | ||
sudo go run canasta.go extension [subcommand] [flags] | ||
**Flags:** | ||
- `-i, --id`: Specifies the Canasta instance ID. | ||
- `-p, --path`: Specifies the Canasta installation directory. | ||
- `-w, --wiki`: Specifies the ID of a specific wiki within the Canasta farm. | ||
- `-v, --verbose`: Enables verbose output. | ||
|
||
## New Commands | ||
|
||
### add | ||
**Description:** Adds a new wiki to a Canasta instance. | ||
|
||
**Usage:** | ||
sudo go run canasta.go add [flags] | ||
**Flags:** | ||
- `-w, --wiki`: ID of the new wiki. | ||
- `-u, --url`: URL of the new wiki. | ||
- `-s, --site-name`: Name of the new wiki site. | ||
- `-p, --path`: Path to the new wiki. | ||
- `-i, --id`: Canasta instance ID. | ||
- `-o, --orchestrator`: Orchestrator to use for installation (default: "docker-compose"). | ||
- `-d, --database`: Path to the existing database dump. | ||
|
||
### remove | ||
**Description:** Removes a wiki from a Canasta instance. | ||
|
||
**Usage:** | ||
sudo go run canasta.go remove [flags] | ||
**Flags:** | ||
- `-w, --wiki`: ID of the wiki to be removed. | ||
- `-p, --path`: Path to the wiki. | ||
- `-i, --id`: Canasta instance ID. | ||
|
||
Download and install the latest package to start using the CLI. For more information on using the CLI, please see the [documentation](https://canasta.wiki/cli). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
package add | ||
|
||
import ( | ||
"fmt" | ||
"log" | ||
"os" | ||
|
||
"github.com/spf13/cobra" | ||
|
||
"github.com/CanastaWiki/Canasta-CLI-Go/cmd/restart" | ||
"github.com/CanastaWiki/Canasta-CLI-Go/internal/canasta" | ||
"github.com/CanastaWiki/Canasta-CLI-Go/internal/config" | ||
"github.com/CanastaWiki/Canasta-CLI-Go/internal/farmsettings" | ||
"github.com/CanastaWiki/Canasta-CLI-Go/internal/mediawiki" | ||
"github.com/CanastaWiki/Canasta-CLI-Go/internal/orchestrators" | ||
"github.com/CanastaWiki/Canasta-CLI-Go/internal/prompt" | ||
) | ||
|
||
func NewCmdCreate() *cobra.Command { | ||
var instance config.Installation | ||
var wikiName string | ||
var domainName string | ||
var wikiPath string | ||
var siteName string | ||
var databasePath string | ||
var url string | ||
var admin string | ||
|
||
addCmd := &cobra.Command{ | ||
Use: "add", | ||
Short: "Add a new wiki to a Canasta instance", | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
var err error | ||
wikiName, domainName, wikiPath, instance.Id, siteName, admin, err = prompt.PromptWiki(wikiName, url, instance.Id, siteName, admin) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
fmt.Printf("Adding wiki '%s' to Canasta instance '%s'...\n", wikiName, instance.Id) | ||
err = AddWiki(wikiName, domainName, wikiPath, siteName, databasePath, admin, instance) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
fmt.Println("Done.") | ||
return nil | ||
}, | ||
} | ||
|
||
pwd, err := os.Getwd() | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
addCmd.Flags().StringVarP(&wikiName, "wiki", "w", "", "ID of the new wiki") | ||
addCmd.Flags().StringVarP(&url, "url", "u", "", "URL of the new wiki") | ||
addCmd.Flags().StringVarP(&siteName, "site-name", "s", "", "Name of the new wiki site") | ||
addCmd.Flags().StringVarP(&instance.Path, "path", "p", pwd, "Path to the new wiki") | ||
addCmd.Flags().StringVarP(&instance.Id, "id", "i", "", "Canasta instance ID") | ||
addCmd.Flags().StringVarP(&instance.Orchestrator, "orchestrator", "o", "docker-compose", "Orchestrator to use for installation") | ||
addCmd.Flags().StringVarP(&databasePath, "database", "d", "", "Path to the existing database dump") | ||
addCmd.Flags().StringVarP(&admin, "admin", "a", "", "Admin name of the new wiki") | ||
return addCmd | ||
} | ||
|
||
// addWiki accepts the Canasta instance ID, the name, domain and path of the new wiki, and the initial admin info, then creates a new wiki in the instance. | ||
func AddWiki(name, domain, wikipath, siteName, databasePath, admin string, instance config.Installation) error { | ||
var err error | ||
|
||
//Checking Installation existence | ||
instance, err = canasta.CheckCanastaId(instance) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
//Migrate to the new version Canasta | ||
err = canasta.MigrateToNewVersion(instance.Path) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
//Checking Running status | ||
err = orchestrators.CheckRunningStatus(instance.Path, instance.Id, instance.Orchestrator) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
//Checking Wiki existence | ||
exists, pathComboExists, err := farmsettings.CheckWiki(instance.Path, name, domain, wikipath) | ||
if err != nil { | ||
return err | ||
} | ||
if exists { | ||
return fmt.Errorf("A wiki with the name '%s' exists", name) | ||
} | ||
if pathComboExists { | ||
return fmt.Errorf("A wiki with the same installation path '%s' in the Canasta '%s' exists", name+": "+domain+"/"+wikipath, instance.Id) | ||
} | ||
|
||
//Add the wiki in farmsettings | ||
err = farmsettings.AddWiki(name, instance.Path, domain, wikipath, siteName) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
// Import the database if databasePath is specified | ||
if databasePath != "" { | ||
err = orchestrators.ImportDatabase(name, databasePath, instance) | ||
if err != nil { | ||
return err | ||
} | ||
} | ||
|
||
//Copy the Localsettings | ||
err = canasta.CopySetting(instance.Path, name) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
//Rewrite the Caddyfile | ||
err = canasta.RewriteCaddy(instance.Path) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
err = mediawiki.InstallOne(instance.Path, name, domain, wikipath, admin,instance.Orchestrator) | ||
if err != nil { | ||
return err | ||
} | ||
err = restart.Restart(instance) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
fmt.Println("Successfully Added the Wiki '" + name + "in Canasta instance '" + instance.Id + "'...") | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.