pkg

package
v0.0.0-...-e36345d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 10, 2021 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BackupDatabase

func BackupDatabase(data *Data)

func Bot

func Bot(botToken string) *tb.Bot

func CheckIfNamedContainerIsRunning

func CheckIfNamedContainerIsRunning(nameInQuestion string) (bool, error)

func ConnectAndExecute

func ConnectAndExecute(
	data *Data,
	sshData SSHConnectionData,
	cmd string,
) (bytes.Buffer, error)

func ContinuousDBBackups

func ContinuousDBBackups(data *Data)

func ExecNoShell

func ExecNoShell(command []string) (string, error)

func ExecuteCmd

func ExecuteCmd(command string) (string, error)

func ExecuteCmds

func ExecuteCmds(commands []string)

func GetConfig

func GetConfig(data *Data, sshData SSHConnectionData) (*ssh.ClientConfig, error)

func GetMainChat

func GetMainChat(chatID int64) *tb.Chat

func PerformBaseBackup

func PerformBaseBackup(data *Data)

func PerformContinuity

func PerformContinuity(data *Data) error

func PeriodicDBBackups

func PeriodicDBBackups(data *Data)

func PublicKeyFile

func PublicKeyFile(file string) (ssh.AuthMethod, error)

func RandString

func RandString(n int) string

func RegisterHandlers

func RegisterHandlers(b *tb.Bot, data *Data)

func SFTP

func SFTP(
	data *Data,
	sshData SSHConnectionData,
	remoteFile,
	localFile string,
) error

func TemporaryNginx

func TemporaryNginx(
	data *Data,
	addressChan chan string,
	minutes int,
	basicAuthUsername,
	basicAuthPassword string,
)

func VerifySender

func VerifySender(data *Data, m *tb.Message) bool

Types

type Config

type Config struct {
	TGBotToken      string `env:"PG_VAKT_TG_BOT_TOKEN"`
	MainChatId      int64  `env:"PG_VAKT_TG_CHAT_ID"`
	IntervalMinutes int    `env:"PG_VAKT_INTERVAL_MINUTES"`
	Continuous      bool   `env:"PG_VAKT_CONTINUOUS"`
	ContinuousPath  string `env:"PG_VAKT_CONTINUOUS_PATH"`
	SSHUser         string `env:"PG_VAKT_SSH_USER"`
	SSHHostname     string `env:"PG_VAKT_SSH_HOSTNAME"`
	SSHKeyFilename  string `env:"PG_VAKT_SSH_KEY_FILENAME"`
	ContainerName   string `env:"PG_VAKT_CONTAINER_NAME"`
	Database        string `env:"PG_VAKT_DATABASE"`
}

type Data

type Data struct {
	B         *tb.Bot
	Chat      *tb.Chat
	Config    Config
	MediaPath string
}

func InitData

func InitData() *Data

func (*Data) CreateMediaDirIfNotExists

func (d *Data) CreateMediaDirIfNotExists(dirname string) string

CreateMediaDirIfNotExists creates the directory in default media path. It can accept nested directory path, but all parent directories must exist. Returns full directory path.

func (*Data) JustSend

func (d *Data) JustSend(to tb.Recipient, msg interface{}, options ...interface{})

func (*Data) Send

func (d *Data) Send(msg interface{}, options ...interface{})

func (*Data) SendSync

func (d *Data) SendSync(msg interface{}, options ...interface{}) (*tb.Message, error)

type SSHConnectionData

type SSHConnectionData struct {
	Hostname string
	Username string
	Keypath  string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL