forked from ModStation/ModStation
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmod-enable.sh
More file actions
47 lines (38 loc) · 904 Bytes
/
Copy pathmod-enable.sh
File metadata and controls
47 lines (38 loc) · 904 Bytes
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
#!/bin/bash
BASEDME="modstation.dme"
if [ $# -ne 1 ]
then
echo "Usage: `basename $0` [module]"
exit
fi
# Checks for module files.
if [ ! -d "modules/${1}" ]
then
echo "Error: Module '$1' doesn't exist."
exit
fi
if [ ! -f "modules/${1}/${1}.dme" ]
then
echo "Error: Module '${1}' doesn't have a .dme file."
exit
fi
if [ ! -f "modules/${1}/${1}.int" ]
then
echo "Warning: Module '${1}' doesn't have a .int file."
fi
# Module is (mostly) valid, we can continue.
#Generate the #include line...
DMEINCLUDE='#include "modules\\'${1}'\\'${1}'.dme"'
#Make sure the module isn't already enabled.
grep -q "$DMEINCLUDE" $BASEDME
if [ $? -eq 0 ]
then
echo "Error: Module '${1}' is already enabled."
exit
fi
#Apply the #include line to the base .dme.
sed -i "/\/\/ BEGIN_INCLUDE/ { N; s/\/\/ BEGIN_INCLUDE\n/${DMEINCLUDE}\n&/ }" \
$BASEDME
#And we're done.
echo "Successfully enabled '${1}'".
exit