-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodlist.sh
More file actions
128 lines (116 loc) · 3.35 KB
/
modlist.sh
File metadata and controls
128 lines (116 loc) · 3.35 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#!/bin/sh
# NOTE THIS WAS MADE FOR WINDOWS GITBASH. YOUR MILEAGE MAY VARY.
#
# THE PATHS NEED TO BE CHANGED IF YOU RUN THIS, OBVIOUSLY.
#
CKAN="/d/SteamLibrary_2/steamapps/common/Kerbal Space Program/GameData/ckan.exe"
#WHICHKSP="Kerbal Space Program v1.10.1" # the CKAN name for the install to use
#WHICHKSP="Kerbal Space Program v1.10.1 RP-1"
#WHICHKSP="auto"
#WHICHKSP="Kerbal Space Program v1.10.1 Beyond Home"
WHICHKSP="Kerbal Space Program v1.12.2 - stream"
STARTDIR="${PWD}"
STAGINGDIR="${STARTDIR}/html-staging/"
GHPAGESDIR="${STARTDIR}/html/"
MODFILENAME="modlist.html"
MODFILESTAGING="${STAGINGDIR}${MODFILENAME}"
echo "GENERATING NEW MOD LIST FILE"
cat > ${MODFILESTAGING} <<ENDMARK
<!doctype html>
<head>
<title>Dunbaratu autogenerated KSP mod list</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<style>
html {
background: #222224;
margin: 0;
}
body {
font-family: sans-serif;
margin: 0;
background: #fff;
padding: 1px;
overflow: auto;
}
section {
margin: 1.7cm 0.5cm;
}
@media only screen and (min-width: 800px) {
body {
max-width: 800px;
margin: 1cm auto;
}
section {
margin: 1.7cm;
}
}
</style>
</head>
<body>
<section>
<h3>Dunbaratu autogenerated KSP mod list</h3>
<p>
The file you are viewing was generated at: <code> `date` (UTC)</code>
</p>
<p>
The CKAN name for this instance of KSP is <code>"${WHICHKSP}"</code>.
</p>
<ul>
ENDMARK
# THIS IS A FRAGILE SCRIPT BASED ON LOOKING AT THE TEXT
# OUTPUT OF THE CKAN list -- porcelain COMMAND. IF CKAN
# CHANGES THEIR OUTPUT FORMAT, THIS SCRIPT WILL BREAK.
# A List of Mods one per line:
# Some of these lines have preceding "- ","+ ", or "A " strings
# on the lefthand side, which have to do with how the mod got installed,
# so the script strips and ignores those prefix strings if they exist.
if [ "${WHICHKSP}" = "auto" ]
then
"Using Default CKAN instance."
else
"$CKAN" instance default "${WHICHKSP}"
fi
"$CKAN" list --porcelain \
| sed 's/^[+-A^] \([^ ]*\).*$/ <li>\1<\/li>/g' \
| sed '/ICSharpCode/d' \
>> ${MODFILESTAGING}
cat >> "${MODFILESTAGING}" << ENDMARK
</ul>
</section>
<section>
<h4>Where is the script</h4>
<small>
The script that automatically generates this list, called
<code>${0}</code>, is located in the master branch of this
git repository (not gh-pages). (In a nutshell, when it
runs it has CKAN print out the mod list, wraps it in some
HTML markup, and pushes the resulting file to this repo's
gh-pages branch so you can see it here.)
</small>
</section>
</body>
ENDMARK
#
# Now the git commands to push the output file to git
#
echo "NEW MOD LIST: ${MODFILESTAGING}"
echo -n "DO YOU WISH TO COMMIT AND PUSH IT UP? (y/n)? "
read yesno
if [ "$yesno" = "y" -o "$yesno" = "Y" ]
then
echo "SWITCHING TO GH-PAGES"
cd "${GHPAGESDIR}"
echo "COPYING HTML OUTPUT TO GH-PAGES".
cp "${MODFILESTAGING}" "${GHPAGESDIR}"
echo "PUSHING"
git add "${MODFILENAME}"
git commit -m "Autocommit by $0" "${MODFILENAME}"
git push origin gh-pages
echo "DONE PUSHING"
echo "SWITCHING TO MASTER"
cd "${STARTDIR}"
git checkout master
else
echo "NOT PUSHING"
fi