-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwp-newprefix
executable file
·104 lines (85 loc) · 2.03 KB
/
wp-newprefix
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
#!/bin/bash
PLATFORM_DIR="$(cd "$(dirname "$0")"; pwd)"
LIB_DIR="${PLATFORM_DIR}"/lib
PRESETS_DIR="${PLATFORM_DIR}"/presets
print_usage() {
echo "Usage: $0 [-S] [-p preset...] <path>"
echo " $0 -l"
echo " $0 -h"
echo
echo "Creates a winepreset prefix in the supplied path."
echo
echo " -S do not execute setup script"
echo " -h print this help text"
echo " -l list available presets"
echo " -p preset inherit preset"
exit
}
list_presets() {
echo 'Available presets:'
for file in "${PRESETS_DIR}"/*.sh; do
preset_name="$(sed 's/\.sh$//' <<< "$(basename "${file}")")"
echo " - ${preset_name}"
done
exit
}
create_prefix() {
echo "installing to $install_dir"
set -e
if ! [[ -d "${install_dir}" ]]; then
mkdir "${install_dir}"
fi
ln -s "${PLATFORM_DIR}" "${install_dir}"/platform
(
echo '# Set up paths'
echo '# Make sure to edit this when moving the directory.'
echo "WP_DATA_PATH='$(cd "${install_dir}"; pwd)'"
echo 'WP_PLATFORM_PATH="${WP_DATA_PATH}"/platform'
echo
echo '# Load platform library'
echo 'source "${WP_PLATFORM_PATH}"/lib/init.sh'
echo
echo '# Inherit presets'
for preset in "${presets[@]}"; do
echo "inherit '$preset'"
done
echo
echo '# Initialize variables; this must be called, and must be called after all calls'
echo '# to inherit'
echo 'wp_init'
) > "${install_dir}"/env
(
cd "${install_dir}"
set +e
source ./env
wp_setup
)
}
no_setup=0
presets=()
while getopts 'CShlp:' arg; do
case ${arg} in
S)
no_setup=1
;;
h)
print_usage
;;
l)
list_presets
;;
p)
presets+=("${OPTARG}")
;;
*)
print_usage
;;
esac
done
shift $((OPTIND-1))
if [[ "${#@}" -eq 0 ]]; then
print_usage
fi
install_dir="$1"
presets=(common "${presets[@]}")
create_prefix