Skip to content

Commit

Permalink
Helper scripts (bigbluebutton#298)
Browse files Browse the repository at this point in the history
* Added helper scripts

* Added commit tag to version tag to builds from master

* Restored script for Travis

* Restored script for Jenkins

* Restored script for Jenkins

* Restored script for Jenkins
  • Loading branch information
jfederico authored Oct 16, 2018
1 parent ec250f3 commit 1617b7d
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ vendor/bundle

# Ignore environment configuration.
.env
env

# IDEs
.idea
Expand Down
4 changes: 2 additions & 2 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ volumes: [
withCredentials([file(credentialsId: 'cloud-datastore-user-account-creds', variable: 'FILE'), string(credentialsId: 'DOCKER_USER', variable: 'DOCKER_USER'), string(credentialsId: 'DOCKER_PASSWORD', variable: 'DOCKER_PASSWORD')]) {
sh "gcloud auth activate-service-account --key-file=$FILE"
if (stageBuild) {
sh "sed -i 's/VERSION =.*/VERSION = \"${gitBranch}\"/g' config/initializers/version.rb"
sh "sed -i 's/VERSION =.*/VERSION = \"${gitBranch} (${gitCommit.substring(7)})\"/g' config/initializers/version.rb"
sh "gcloud docker -- build -t ${imageTag} -t 'bigbluebutton/${appName}:master' . && gcloud docker -- push ${imageTag}"
sh "docker login -u $DOCKER_USER -p $DOCKER_PASSWORD"
sh "docker push 'bigbluebutton/${appName}:master'"
Expand Down Expand Up @@ -93,4 +93,4 @@ volumes: [
slackSend (color: '#FF0000', message: "FAILED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]' message: ${e} (${env.BUILD_URL})")
}
}
}
}
13 changes: 13 additions & 0 deletions scripts/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Helpers

## Running automatic updates

```
sudo ln -s /root/greenlight/scripts/deploy.sh /usr/local/bin/greenlight-deploy
sudo cp /root/greenlight/scripts/greenlight-auto-deployer.service /etc/systemd/system/greenlight-auto-deployer.service
sudo cp /root/greenlight/scripts/greenlight-auto-deployer.timer /etc/systemd/system/greenlight-auto-deployer.timer
sudo systemctl daemon-reload
sudo systemctl enable greenlight-auto-deployer.service
sudo systemctl enable greenlight-auto-deployer.timer
sudo systemctl start greenlight-auto-deployer.timer
```
17 changes: 17 additions & 0 deletions scripts/deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

STATUS="Status: Downloaded newer image for bigbluebutton/greenlight:v2"

new_status=$(sudo docker pull bigbluebutton/greenlight:v2 | grep Status:)

echo $new_status

if [ "$STATUS" == "$new_status" ]
then
cd /home/ubuntu/greenlight
sudo docker-compose down
sudo docker rmi $(sudo docker images -f dangling=true -q)
sudo docker-compose up -d
fi

exit 0
5 changes: 5 additions & 0 deletions scripts/greenlight-auto-deployer.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[Unit]
Description=Greenlight Auto Deployer

[Service]
ExecStart=/bin/bash /usr/local/bin/greenlight-deploy
12 changes: 12 additions & 0 deletions scripts/greenlight-auto-deployer.timer
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[Unit]
Description=Runs greenlight-deploy every minute

[Timer]
# Time to wait after booting before we run first time
OnBootSec=1min
# Time between running each consecutive time
OnUnitActiveSec=1m
Unit=greenlight-auto-deployer.service

[Install]
WantedBy=multi-user.target

0 comments on commit 1617b7d

Please sign in to comment.