Add 'wdcli monday' command
This commit is contained in:
parent
fc3b9170a6
commit
df4cfa3567
7 changed files with 75 additions and 110 deletions
71
cmd/monday.go
Normal file
71
cmd/monday.go
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
package cmd
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
wisski_distillery "github.com/FAU-CDI/wisski-distillery"
|
||||
"github.com/FAU-CDI/wisski-distillery/env"
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/logging"
|
||||
)
|
||||
|
||||
// Monday is the 'monday' command
|
||||
var Monday wisski_distillery.Command = monday{}
|
||||
|
||||
type monday struct {
|
||||
UpdateInstances bool `short:"u" long:"update-instances" description:"Fully update instances. May take a long time, and is potentially breaking. "`
|
||||
Positionals struct {
|
||||
GraphdbZip string `positional-arg-name:"PATH_TO_GRAPHDB_ZIP" required:"1-1" description:"path to the graphdb.zip file"`
|
||||
} `positional-args:"true"`
|
||||
}
|
||||
|
||||
func (monday) Description() wisski_distillery.Description {
|
||||
return wisski_distillery.Description{
|
||||
Requirements: env.Requirements{
|
||||
NeedsConfig: true,
|
||||
},
|
||||
Command: "monday",
|
||||
Description: "Runs regular monday tasks",
|
||||
}
|
||||
}
|
||||
|
||||
func (monday monday) AfterParse() error {
|
||||
_, err := os.Stat(monday.Positionals.GraphdbZip)
|
||||
if os.IsNotExist(err) {
|
||||
return errNoGraphDBZip.WithMessageF(monday.Positionals.GraphdbZip)
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (monday monday) Run(context wisski_distillery.Context) error {
|
||||
if err := logging.LogOperation(func() error {
|
||||
return context.Exec("backup")
|
||||
}, context.IOStream, "Running backup"); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := logging.LogOperation(func() error {
|
||||
return context.Exec("system_update", monday.Positionals.GraphdbZip)
|
||||
}, context.IOStream, "Running system_update"); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := logging.LogOperation(func() error {
|
||||
return context.Exec("rebuild")
|
||||
}, context.IOStream, "Running rebuild"); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if monday.UpdateInstances {
|
||||
if err := logging.LogOperation(func() error {
|
||||
return context.Exec("blind_update")
|
||||
}, context.IOStream, "Running blind_update"); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
logging.LogMessage(context.IOStream, "Done, have a great week!")
|
||||
return nil
|
||||
}
|
||||
|
|
@ -47,6 +47,7 @@ func init() {
|
|||
wdcli.Register(cmd.Snapshot)
|
||||
wdcli.Register(cmd.Backup)
|
||||
wdcli.Register(cmd.Cron)
|
||||
wdcli.Register(cmd.Monday)
|
||||
}
|
||||
|
||||
// an error when no arguments are provided.
|
||||
|
|
|
|||
|
|
@ -1,34 +0,0 @@
|
|||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
# read the lib/shared.sh and read the slug argument.
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
||||
cd "$DIR"
|
||||
source "$DIR/lib/lib.sh"
|
||||
|
||||
# Read the 'GRAPHDB_ZIP' argument from the command line.
|
||||
# If it's not set, throw an error.
|
||||
GRAPHDB_ZIP=$1
|
||||
if [ -z "$GRAPHDB_ZIP" ]; then
|
||||
log_error "Usage: monday.sh GRAPHDB_ZIP"
|
||||
exit 1;
|
||||
fi;
|
||||
|
||||
|
||||
# Backup
|
||||
log_info " => Running backup, this will take a long time"
|
||||
bash backup_all.sh
|
||||
|
||||
# system install
|
||||
log_info " => Reinstalling system"
|
||||
bash system_install.sh "$GRAPHDB_ZIP"
|
||||
|
||||
# rebuild all the systems
|
||||
log_info " => Rebuilding all instances"
|
||||
bash rebuild_all.sh
|
||||
|
||||
# perform all the blind updates
|
||||
log_info " => Performing updates"
|
||||
bash blind_update_all.sh
|
||||
|
||||
log_info " => Done, have a great week"
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
# read the lib/shared.sh and read the slug argument.
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
||||
cd "$DIR"
|
||||
source "$DIR/lib/lib.sh"
|
||||
|
||||
# Read the 'GRAPHDB_ZIP' argument from the command line.
|
||||
# If it's not set, throw an error.
|
||||
GRAPHDB_ZIP=$1
|
||||
if [ -z "$GRAPHDB_ZIP" ]; then
|
||||
log_error "Usage: monday_short.sh GRAPHDB_ZIP"
|
||||
exit 1;
|
||||
fi;
|
||||
|
||||
|
||||
# Backup
|
||||
log_info " => Running backup, this will take a long time"
|
||||
bash backup_all.sh
|
||||
|
||||
# system install
|
||||
log_info " => Reinstalling system"
|
||||
bash system_install.sh "$GRAPHDB_ZIP"
|
||||
|
||||
# rebuild all the systems
|
||||
log_info " => Rebuilding all instances"
|
||||
bash rebuild_all.sh
|
||||
|
||||
log_info " => Done, have a great week"
|
||||
|
|
@ -1,43 +0,0 @@
|
|||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
# read the lib/shared.sh
|
||||
DISABLE_LOG=1
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
||||
cd "$DIR"
|
||||
source "$DIR/lib/lib.sh"
|
||||
DISABLE_LOG=0
|
||||
|
||||
log_info " => Writing prefix configuration"
|
||||
|
||||
echo -n "# Prefix configuration, last updated on" | tee "$DEPLOY_PREFIX_CONFIG"
|
||||
date | tee -a "$DEPLOY_PREFIX_CONFIG"
|
||||
|
||||
# update all the instances
|
||||
for slug in $(sql_bookkeep_list); do
|
||||
INSTANCE_DOMAIN="$(compute_instance_url "$slug")"
|
||||
|
||||
read -r INSTANCE_BASE_DIR MYSQL_DATABASE MYSQL_USER GRAPHDB_REPO GRAPHDB_USER GRAPHDB_PASSWORD <<< "$(sql_bookkeep_load "${slug}" "filesystem_base,sql_database,sql_user,graphdb_repository,graphdb_user,graphdb_password" | tail -n +2)"
|
||||
|
||||
INSTANCE_NOPREFIX_FILE="$(compute_instance_noprefixfile "$INSTANCE_BASE_DIR" )"
|
||||
INSTANCE_PREFIX_FILE="$(compute_instance_prefixfile "$INSTANCE_BASE_DIR" )"
|
||||
if [ -f "$INSTANCE_NOPREFIX_FILE" ]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
pushd "$INSTANCE_BASE_DIR" > /dev/null
|
||||
|
||||
echo "$INSTANCE_DOMAIN:" | tee -a "$DEPLOY_PREFIX_CONFIG"
|
||||
docker-compose exec barrel /user_shell.sh -c "drush php:script /wisskiutils/list_uri_prefixes.php" | tee -a "$DEPLOY_PREFIX_CONFIG"
|
||||
|
||||
if [ -f "$INSTANCE_PREFIX_FILE" ]; then
|
||||
cat "$INSTANCE_PREFIX_FILE" | tee -a "$DEPLOY_PREFIX_CONFIG"
|
||||
fi
|
||||
|
||||
popd > /dev/null
|
||||
done
|
||||
|
||||
log_info " => Restarting resolver"
|
||||
|
||||
cd "$DEPLOY_RESOLVER_DIR"
|
||||
docker-compose restart
|
||||
2
go.mod
2
go.mod
|
|
@ -7,7 +7,7 @@ require (
|
|||
github.com/alessio/shellescape v1.4.1
|
||||
github.com/feiin/sqlstring v0.3.0
|
||||
github.com/pkg/errors v0.9.1
|
||||
github.com/tkw1536/goprogram v0.0.10
|
||||
github.com/tkw1536/goprogram v0.0.11
|
||||
golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e
|
||||
gorm.io/driver/mysql v1.3.6
|
||||
gorm.io/gorm v1.23.8
|
||||
|
|
|
|||
4
go.sum
4
go.sum
|
|
@ -15,8 +15,8 @@ github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
|
|||
github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
|
||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/tkw1536/goprogram v0.0.10 h1:NRnAW46Vl9ro01eLDhlb7R56HsCls43h2anNXjwMPP4=
|
||||
github.com/tkw1536/goprogram v0.0.10/go.mod h1:rX9MKOpJ9qAu4jHV2+n64SKmm3c2D3Hh1V8zC1H3jB4=
|
||||
github.com/tkw1536/goprogram v0.0.11 h1:RDcPvpObL6mViB2knUj+v0AyP+XL6vvMEA0auB2Ahz4=
|
||||
github.com/tkw1536/goprogram v0.0.11/go.mod h1:rX9MKOpJ9qAu4jHV2+n64SKmm3c2D3Hh1V8zC1H3jB4=
|
||||
golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e h1:+WEEuIdZHnUeJJmEUjyYC2gfUMj69yZXw17EnHg/otA=
|
||||
golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e/go.mod h1:Kr81I6Kryrl9sr8s2FK3vxD90NdsKWRuOIl2O4CvYbA=
|
||||
golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue