diff --git a/README.md b/README.md index 92b3a520..c5c1a01b 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ - Download pre-built binary into a server ```console -curl -fsSL -O https://github.com/appscodelabs/offline-license-server/releases/download/v0.0.9/offline-license-server-linux-amd64 +curl -fsSL -O https://github.com/appscode/offline-license-server/releases/download/v0.0.3/offline-license-server-linux-amd64 chmod +x offline-license-server-linux-amd64 mv offline-license-server-linux-amd64 /usr/local/bin/offline-license-server ``` @@ -13,10 +13,13 @@ mv offline-license-server-linux-amd64 /usr/local/bin/offline-license-server - Install systemd service ```console -curl -fsSL -O https://github.com/appscodelabs/offline-license-server/raw/v0.0.9/hack/systemd/offline-license-server.service +curl -fsSL -O https://github.com/appscode/offline-license-server/raw/v0.0.3/hack/systemd/offline-license-server.service chmod +x offline-license-server.service -# edit offline-license-server.service file to add `--ssl --secret-key=` +# 1. Copy Google cloud service account json key to /root/app/gcloud.json +# 2. Edit offline-license-server.service file to +# - set MAILGUN_KEY +# - add `--ssl` mv offline-license-server.service /lib/systemd/system/offline-license-server.service ``` @@ -33,4 +36,4 @@ sudo journalctl -f -u offline-license-server ``` curl -d "email=tamal@appscode.com" -X POST http://localhost:4000/register -``` \ No newline at end of file +``` diff --git a/cmds/root.go b/cmds/root.go index 0d8e0e84..c3b4b84f 100644 --- a/cmds/root.go +++ b/cmds/root.go @@ -25,8 +25,8 @@ import ( func NewRootCmd() *cobra.Command { rootCmd := &cobra.Command{ - Use: "gh-ci [command]", - Short: `gh-ci by AppsCode - GitHub CI for private repos`, + Use: "offline-license-server [command]", + Short: `offline-license-server by AppsCode - Offline License server for AppsCode products`, DisableAutoGenTag: true, } diff --git a/hack/systemd/offline-license-server.service b/hack/systemd/offline-license-server.service index 4e7a1b2b..7f87838c 100755 --- a/hack/systemd/offline-license-server.service +++ b/hack/systemd/offline-license-server.service @@ -1,6 +1,6 @@ # ref: https://fabianlee.org/2017/05/21/golang-running-a-go-binary-as-a-systemd-service-on-ubuntu-16-04/ [Unit] -Description=GitHub CI Webhook Service +Description=AppsCode Offline License Server After=network.target [Service] @@ -13,9 +13,10 @@ Restart=on-failure RestartSec=10 startLimitIntervalSec=60 -# GitHub Env Vars -Environment=GITHUB_USER=1gtm -Environment=GITHUB_TOKEN= +# Env Vars +Environment=GOOGLE_APPLICATION_CREDENTIALS=/root/app/gcloud.json +Environment=MAILGUN_DOMAIN=mail.appscode.com +Environment=MAILGUN_KEY= WorkingDirectory=/root ExecStart=/usr/local/bin/offline-license-server run diff --git a/pkg/server/options.go b/pkg/server/options.go index ef77a28c..9f72f229 100644 --- a/pkg/server/options.go +++ b/pkg/server/options.go @@ -44,8 +44,8 @@ type Options struct { MailReplyTo string } -func NewOptions() Options { - return Options{ +func NewOptions() *Options { + return &Options{ CertDir: "certs", CertEmail: "tamal@appscode.com", Hosts: []string{"license-issuer.appscode.com"}, @@ -59,7 +59,7 @@ func NewOptions() Options { } } -func (s Options) AddFlags(fs *pflag.FlagSet) { +func (s *Options) AddFlags(fs *pflag.FlagSet) { fs.StringVar(&s.CertDir, "ssl.cert-dir", s.CertDir, "Directory where certs are stored") fs.StringVar(&s.CertEmail, "ssl.email", s.CertEmail, "Email used by Let's Encrypt to notify about problems with issued certificates") fs.StringSliceVar(&s.Hosts, "ssl.hosts", s.Hosts, "Hosts for which certificate will be issued") diff --git a/pkg/server/server.go b/pkg/server/server.go index 33f17882..909af3c8 100644 --- a/pkg/server/server.go +++ b/pkg/server/server.go @@ -43,14 +43,14 @@ import ( ) type Server struct { - opts Options + opts *Options certs *certstore.CertStore fs *blobfs.BlobFS mg mailgun.Mailgun } -func New(opts Options) (*Server, error) { +func New(opts *Options) (*Server, error) { fs := blobfs.New("gs://" + opts.LicenseBucket) certs, err := certstore.New(fs, CACertificatesPath(), LicenseIssuerName) if err != nil {