-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathsetup
More file actions
executable file
·50 lines (44 loc) · 1.28 KB
/
setup
File metadata and controls
executable file
·50 lines (44 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/bash
set_dir () { DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"; }; set_dir
safe_source () { source $1; set_dir; }
set_dir
safe_source $DIR/aktos-bash-lib/btrfs-functions.sh
PR=$(realpath $DIR/..)
echo "Project root is: $PR"
CONFIG="$PR/config.sh"
echo "Creating link for Makefile"
ln -sf "./$(basename $DIR)/toolset-makefile.mk" "$PR/Makefile"
echo "Creating backups directory"
backups_dir="$PR/backups"
if [ ! -d $backups_dir ]; then
mkdir -p $PR/backups
else
echo "..backups dir exists already."
fi
sync_root="$PR/sync-root"
btrfs_flag="$PR/method-btrfs"
hardlinks_flag="$PR/method-hardlinks"
if [ ! -d $sync_root ]; then
echo "Guessing preferred backup method.."
if is_btrfs "$PR"; then
echo "..using btrfs method"
touch $btrfs_flag
rm $hardlinks_flag 2> /dev/null
btrfs sub create $sync_root
else
echo "..using hardlinks method"
touch $hardlinks_flag
rm $btrfs_flag 2> /dev/null
mkdir $sync_root
fi
else
echo "..sync-root exists already, not configuring again."
fi
echo "Creating configuration file"
if [[ ! -e "$CONFIG" ]]; then
cp "$DIR/config-template.sh" "$CONFIG"
nano "$CONFIG"
else
echo "..there is a configuration file already, use 'make setup' to setup"
fi
touch "$PR/up-to-date"