-
Notifications
You must be signed in to change notification settings - Fork 5
/
setuppigen.sh
executable file
·51 lines (47 loc) · 1.11 KB
/
setuppigen.sh
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
51
#!/bin/bash
#!/bin/bash
#
# pi-gen-utils project
#
# Copyright (c) 2020, Francis Turner
# All rights reserved.
#
# Copy files of the from bak subdirectory back into the various pi-gen directories
# and delete any other files in the pi-gen directory tree that have
# equivalent files in this directory
#
# Usage: setuppigen.sh [pi-gen-dir]
#
# If a pigen directory is specified on the command line it is used, if not
# then if the environment variable PP is set use that, otherwise assume
# the pi-gen directory is at '../pi-gen'
#
# Note there is very little error checking
#
PP=${1-${PP-'../pi-gen'}}
if [ ! -d $PP ] ; then
echo Directory '"'$PP'"' does not exist, cannot copy files to it
exit 1
fi
echo "pi-gen directory: $PP"
if [ ! -e bak ] ; then
mkdir bak
fi
for F in stage* export*; do
if [ ! -e $F ] ; then
continue
fi
D=`echo $F | sed 's/_/\//g' | sed 's!//!_!'`
if [ -e $PP/$D ] ; then
if [ -e bak/$F ]; then
echo "Backup $F already present, skipping"
else
echo "Backing up $D"
cp $PP/$D bak/$F
fi
else
echo "New file $F, skipping backup"
fi
cp $F $PP/$D
done
cp config $PP