Skip to content

Commit

Permalink
Make a release for standalone install
Browse files Browse the repository at this point in the history
  • Loading branch information
ke4roh committed Oct 26, 2020
1 parent 9e8cc78 commit 7a2334b
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
hosts
calendar-install-*.run
package
makeself-2.4.2*
playbook.retry
29 changes: 29 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
CALENDAR_VER=`cat release_number.txt`
MAKESELF_VER=2.4.2

makeself-$(MAKESELF_VER)/makeself.sh:
wget --quiet https://github.com/megastep/makeself/releases/download/release-$(MAKESELF_VER)/makeself-$(MAKESELF_VER).run
sh ./makeself-$(MAKESELF_VER).run
rm makeself-$(MAKESELF_VER).run

calendar-install-$(CALENDAR_VER).run: makeself-$(MAKESELF_VER)/makeself.sh install.sh hosts-localhost playbook.yml $(wildcard roles/**/*)
mkdir -p package
cp -r hosts-localhost install.sh roles playbook.yml package/.
# makeself.sh [args] archive_dir file_name label startup_script [script_args]
makeself-$(MAKESELF_VER)/makeself.sh package calendar-install-$(CALENDAR_VER).run "Installing setup scripts" install.sh


.PHONY: clean package release

clean:
rm -rf package calendar-install-*.run

package: calendar-install-$(CALENDAR_VER).run

release: package
git tag r$(CALENDAR_VER)
git push origin
curl -X POST -H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/jscarbor/rpi-calendar/releases \
-d '{"tag_name":"'r$(CALENDAR_VER)'"}'
expr $(CALENDAR_VER) + 1 >release_number.txt
29 changes: 29 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash

function makeFileWithMode {
[[ -f $1 ]] || (touch $1 ; chmod $2 $1)
}

# assume sudo permission (it is default)

# check ssh is turned on
sudo systemctl status ssh | grep -q "Active: active" || sudo systemctl start ssh
sudo systemctl status ssh | grep Loaded: | grep -q enabled || sudo systemctl enable ssh

# check ssh keygen ran for pi
[[ -f /home/pi/.ssh/id_rsa ]] || (echo -e "\n\n\n" | ssh-keygen 2>&1 >/dev/null)

# check pi has its own authorized_key
ak="/home/pi/.ssh/authorized_keys"
makeFileWithMode $ak 600
grep -q "$(cat /home/pi/.ssh/id_rsa.pub)" $ak || (cat /home/pi/.ssh/id_rsa.pub >> $ak)

# check pi has the localhost known_host
kh="/home/pi/.ssh/known_hosts"
makeFileWithMode $kh 600
grep -q localhost $kh | ssh-keyscan localhost >>$kh

# install Ansible if necessary
sudo dpkg -s ansible 2>&1 >/dev/null || sudo apt-get install ansible

ansible-playbook playbook.yml -i hosts-localhost -u pi
1 change: 1 addition & 0 deletions release_number.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1

0 comments on commit 7a2334b

Please sign in to comment.