-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #425 from qdraw/feature/202107_bugfixes_10
no filestream to log && add mac os script
- Loading branch information
Showing
3 changed files
with
80 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#!/bin/bash | ||
|
||
# Mac OS only: | ||
# launchctl load -w ~/Library/LaunchAgents/starsky.importer.plist | ||
# launchctl unload ~/Library/LaunchAgents/starsky.importer.plist | ||
# chmod +x /opt/starsky/import.sh | ||
# replace data_disk with your disk name | ||
|
||
BACKUP_DIR="/Volumes/data_disk/storage/fotobiebbak" | ||
|
||
|
||
LOCKFILE="/tmp/importd.lock" | ||
|
||
# lock file | ||
if [ -f $LOCKFILE ]; then | ||
# Control will enter here if file exists. | ||
if [ "$(( $(date +"%s") - $(stat -f "%m" "$LOCKFILE") ))" -gt "3600" ]; then | ||
echo "$LOCKFILE is older then 1 hour" | ||
rm $LOCKFILE | ||
fi | ||
|
||
if [ -f $LOCKFILE ]; then | ||
if [ "$(( $(date +"%s") - $(stat -f "%m" "$LOCKFILE") ))" -lt "3600" ]; then | ||
echo "$LOCKFILE is younger than 1 hour" | ||
exit 1 | ||
fi | ||
fi | ||
fi | ||
|
||
if [ ! -f $LOCKFILE ]; then | ||
touch $LOCKFILE | ||
fi | ||
|
||
echo "script started" | ||
# end lock file | ||
|
||
find /Volumes -type d -maxdepth 2 -name "DCIM" -print0 | | ||
while IFS= read -r -d '' line; | ||
do | ||
echo "$line" | ||
# just copy | ||
/opt/starsky/starsky/starskyimportercli --recursive true -v true -i false --path $line --structure "/yyyyMMdd_HHmmss_{filenamebase}.ext" --basepath $BACKUP_DIR -x false | ||
|
||
# import | ||
/opt/starsky/starsky/starskyimportercli --recursive true -v true --move true -i true --path $line | ||
done | ||
|
||
# lock file | ||
echo "script ended" | ||
|
||
if [ -f $LOCKFILE ]; then | ||
echo "Lockfile removed" | ||
rm $LOCKFILE | ||
fi | ||
# end lock file |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>Label</key> | ||
<string>starsky.importer</string> | ||
<key>ProgramArguments</key> | ||
<array> | ||
<string>sh</string> | ||
<string>-c</string> | ||
<string>/opt/starsky/starsky-importer.sh</string> | ||
</array> | ||
<key>WatchPaths</key> | ||
<array> | ||
<string>/Volumes/</string> | ||
</array> | ||
<key>StartOnMount</key> | ||
<true/> | ||
<key>StandardErrorPath</key> | ||
<string>/opt/starsky/z-log-starsky-importer.error.log</string> | ||
<key>StandardOutPath</key> | ||
<string>/opt/starsky/z-log-starsky-importer.out.log</string> | ||
</dict> | ||
</plist> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters