checkin - statuper shell script

pull/78/head
Hunter Long 2018-10-04 23:04:26 -07:00
parent a44b0f2b9e
commit 69c93bcf85
2 changed files with 29 additions and 16 deletions

View File

@ -103,7 +103,7 @@ func (u *CheckinHit) Create() (int64, error) {
u.CreatedAt = time.Now() u.CreatedAt = time.Now()
} }
row := checkinHitsDB().Create(u) row := checkinHitsDB().Create(u)
if row.Error == nil { if row.Error != nil {
utils.Log(2, row.Error) utils.Log(2, row.Error)
return 0, row.Error return 0, row.Error
} }
@ -119,7 +119,7 @@ func SelectCheckinApi(api string) *Checkin {
func (c *Checkin) CreateHit() (int64, error) { func (c *Checkin) CreateHit() (int64, error) {
c.CreatedAt = time.Now() c.CreatedAt = time.Now()
row := checkinDB().Create(c) row := checkinDB().Create(c)
if row.Error == nil { if row.Error != nil {
utils.Log(2, row.Error) utils.Log(2, row.Error)
return 0, row.Error return 0, row.Error
} }

View File

@ -1,12 +1,13 @@
#!/usr/bin/env bash #!/usr/bin/env bash
VERSION="3.4.0" VERSION="0.1"
VERBOSE=false VERBOSE=false
SSLOPTION=false SSLOPTION=false
AWSREGION="us-west-2" AWSREGION="us-west-2"
US_W_1="ami-7be8a103" US_W_1="ami-6d1ffd0e"
US_W_2="ami-7be8a103" US_W_2="ami-7be8a103"
US_E_1="ami-7be8a103" US_E_1="ami-b3be85cc"
US_E_2="ami-7be8a103" US_E_2="ami-cc7a40a9"
AMI_IMAGE=$US_W_2
AWS_CLI=$(which aws) AWS_CLI=$(which aws)
DOCKER_CLI=$(which docker) DOCKER_CLI=$(which docker)
DOCKER_IMG="hunterlong/statup" DOCKER_IMG="hunterlong/statup"
@ -19,16 +20,18 @@ cat <<EOM
A simple shell script that will help you install Statup on your local machine, AWS, or Docker. A simple shell script that will help you install Statup on your local machine, AWS, or Docker.
Commands: Commands:
install Install statup to your local system
aws Create a new EC2 instance running Statup aws Create a new EC2 instance running Statup
docker Start the latest Statup Docker image docker Start the latest Statup Docker image
docker-compose Create Statup with a Postgres database docker-compose Create Statup with a Postgres database
version Return the latest version of Statup
Available Flags: Available Flags:
-k | --aws-access-key AWS Access Key ID. May also be set as environment variable AWS_ACCESS_KEY_ID -k | --aws-access-key AWS Access Key ID. May also be set as environment variable AWS_ACCESS_KEY_ID
-s | --aws-secret-key AWS Secret Access Key. May also be set as environment variable AWS_SECRET_ACCESS_KEY -s | --aws-secret-key AWS Secret Access Key. May also be set as environment variable AWS_SECRET_ACCESS_KEY
-r | --region AWS Region Name. May also be set as environment variable AWS_DEFAULT_REGION -r | --region AWS Region Name. May also be set as environment variable AWS_DEFAULT_REGION
-v | --version Print out the current version of this tool
-x | --verbose Verbose output -x | --verbose Verbose output
Visit the github repo at: https://github.com/hunterlong/statup Visit the github repo at: https://github.com/hunterlong/statup
EOM EOM
exit 3 exit 3
@ -241,6 +244,10 @@ function localTask {
fi fi
} }
function uninstallTask {
rm -f /usr/local/bin/statup
}
# start the Statup docker image # start the Statup docker image
function dockerTask { function dockerTask {
echo "Starting Statup Docker container on port $DOCKER_PORT" echo "Starting Statup Docker container on port $DOCKER_PORT"
@ -283,6 +290,13 @@ function getOS {
esac esac
} }
function echoVersion {
require jq
get_latest_release
echo "Statup Latest: $STATUP_VERSION"
echo "Statuper Tool: v$VERSION"
}
# main CLI entrypoint # main CLI entrypoint
if [ "$BASH_SOURCE" == "$0" ]; then if [ "$BASH_SOURCE" == "$0" ]; then
set -o errexit set -o errexit
@ -318,15 +332,6 @@ if [ "$BASH_SOURCE" == "$0" ]; then
-x|--verbose) -x|--verbose)
VERBOSE=true VERBOSE=true
;; ;;
-v|--version)
require jq
get_latest_release
echo "Statup Latest: $STATUP_VERSION"
echo "Statuper Tool: v$VERSION"
getOS
echo $OS
exit 0
;;
*) *)
;; ;;
esac esac
@ -361,6 +366,14 @@ if [ "$BASH_SOURCE" == "$0" ]; then
localTask localTask
shift # past argument shift # past argument
;; ;;
uninstall)
uninstallTask
shift # past argument
;;
version|v)
echoVersion
exit 0
;;
*) *)
;; ;;
esac esac