Skip to content

Commit d3495fc

Browse files
committed
Refactor repository to be managed by a Makefile
1 parent daa107a commit d3495fc

File tree

9 files changed

+83
-34
lines changed

9 files changed

+83
-34
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ notifications:
66
sudo: false
77

88
script:
9-
- shellcheck asimov *.sh
9+
- shellcheck asimov scripts/*.sh
1010

1111
matrix:
1212
fast_finish: true

Makefile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
all: install
2+
3+
.PHONY: install
4+
install:
5+
@scripts/install.sh
6+
7+
.PHONY: uninstall
8+
uninstall:
9+
@scripts/uninstall.sh

README.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,16 @@ To get started with Asimov, clone the repository or download and extract an arch
1818
$ git clone git@github.com:stevegrunwell/asimov.git
1919
```
2020

21-
After you've cloned the repository, run the `install.sh` script to automatically:
22-
* Symlink Asimov to `/usr/local/bin`, making it readily available from anywhere.
23-
* Schedule Asimov to run once a day, ensuring new projects' dependencies are quickly excluded from Time Machine backups.
24-
* Run Asimov for the first time, finding all current project dependencies adding them to Time Machine's exclusion list.
21+
After you've cloned the repository :
22+
* [optional] before installing, you can edit `com.stevegrunwell.asimov.plist` to change the scheduling of Asimov (default to once a day)
23+
* run a `make` command to automatically :
24+
* Copy Asimov to `/usr/local/bin`, making it readily available from anywhere.
25+
* Schedule Asimov, ensuring new projects' dependencies are quickly excluded from Time Machine backups.
26+
* Run Asimov for the first time, finding all current project dependencies adding them to Time Machine's exclusion list.
27+
28+
## Uninstall
29+
30+
Simply run `make uninstall` from your cloned repository.
2531

2632
## How it works
2733

TODO.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# TODO
2+
3+
- exclude `.Trash` from scanning
4+
- ensure exclusions from `.vscode` modules does not break them once restored
5+
- ensure exclusions from Applications based on node with a `node_modules` folder does not break them once restored
6+
- Add a parameter to the `install.sh` script to set the `StartInterval`
7+
- Make a brew formulae

com.stevegrunwell.asimov.plist

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@
77
<key>Program</key>
88
<string>/usr/local/bin/asimov</string>
99
<key>StartInterval</key>
10-
<!-- 24 hours = 60 * 60 * 24 -->
10+
<!-- 24 hours = 60 * 60 * 24 = 86400 -->
11+
<!-- 12 hours = 60 * 60 * 12 = 43200 -->
12+
<!-- 6 hours = 60 * 60 * 6 = 21600 -->
13+
<!-- 2 hours = 60 * 60 * 2 = 7200 -->
14+
<!-- 1 hour = 60 * 60 = 3600 -->
1115
<integer>86400</integer>
1216
</dict>
1317
</plist>

install.sh

Lines changed: 0 additions & 28 deletions
This file was deleted.

scripts/install.sh

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/usr/bin/env bash
2+
3+
# Install Asimov as a launchd daemon.
4+
#
5+
# @author Steve Grunwell
6+
# @license MIT
7+
8+
# shellcheck source=vars.sh
9+
source "$(pwd -P)/$(dirname $0)/vars.sh"
10+
11+
# Verify that Asimov is executable.
12+
chmod +x "${DIR}/asimov"
13+
14+
# Copy Asimov into /usr/local/bin.
15+
echo -e "\\033[0;36mInstalling to ${BIN}\\033[0m"
16+
cp -a "${DIR}/asimov" "${BIN}"
17+
18+
# Ensure daemon is not already loaded.
19+
if launchctl list | grep -q com.stevegrunwell.asimov; then
20+
echo -e "\\n\\033[0;36mUnloading current instance of ${PLIST}\\033[0m";
21+
launchctl unload "${DIR}/${PLIST}"
22+
fi
23+
24+
# Load the .plist file.
25+
launchctl load "${DIR}/${PLIST}" && echo -e "\\n\\033[0;32mAsimov daemon has been loaded!\\033[0m";
26+
27+
# Run Asimov for the first time.
28+
29+
echo -e "\\nRun Asimov immediately with \\033[0;35m${BIN}\\033[0m"

scripts/uninstall.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env bash
2+
3+
# Uninstall Asimov.
4+
#
5+
# @author Steve Grunwell
6+
# @license MIT
7+
8+
# shellcheck source=vars.sh
9+
source "$(pwd -P)/$(dirname $0)/vars.sh"
10+
11+
echo -e "\\n\\033[0;36mRemoving command ${BIN}\\033[0m";
12+
[[ -f ${BIN} ]] && rm "${BIN}"
13+
14+
if launchctl list | grep -q com.stevegrunwell.asimov; then
15+
echo -e "\\n\\033[0;36mUnloading current instance of ${PLIST}\\033[0m";
16+
launchctl unload "${DIR}/${PLIST}"
17+
fi
18+
19+
echo -e "\\n\\033[0;32mAsimov has been successfully uninstalled.\\033[0m";

scripts/vars.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
DIR="$(pwd -P)"
2+
BIN="/usr/local/bin/asimov"
3+
PLIST="com.stevegrunwell.asimov.plist"

0 commit comments

Comments
 (0)