-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlinux-batch
More file actions
220 lines (178 loc) · 7 KB
/
linux-batch
File metadata and controls
220 lines (178 loc) · 7 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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
#!/bin/bash
cd "$(dirname "$0")"
# ANSI escape codes for colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
BLUE='\033[0;34m'
RESET='\033[0m'
# ANSI escape codes for deleting previous lines
CURSOR_UP='\033[1A'
ERASE_LINE='\033[2K'
linux_batch_arch="32"
banner="""
██╗ ██╗███╗ ██╗██╗ ██╗██╗ ██╗ ██████╗ █████╗ ████████╗ ██████╗██╗ ██╗
██║ ██║████╗ ██║██║ ██║╚██╗██╔╝ ██╔══██╗██╔══██╗╚══██╔══╝██╔════╝██║ ██║
██║ ██║██╔██╗ ██║██║ ██║ ╚███╔╝█████╗██████╔╝███████║ ██║ ██║ ███████║
██║ ██║██║╚██╗██║██║ ██║ ██╔██╗╚════╝██╔══██╗██╔══██║ ██║ ██║ ██╔══██║
███████╗██║██║ ╚████║╚██████╔╝██╔╝ ██╗ ██████╔╝██║ ██║ ██║ ╚██████╗██║ ██║
╚══════╝╚═╝╚═╝ ╚═══╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝╚═╝ ╚═╝
This program is free software, you may redistribute under the terms of the LGPL-3.0
or later.
Although this is distributed in the hopes that it will be useful, it is provided
without any warranty;
without even the implied warranty of merchantability or fitness for a particular
purpose.
"""
# Display an animation of colors in the banner
colors=("$RED" "$GREEN" "$YELLOW" "$BLUE")
IFS=$'\n' read -rd '' -a banner_lines <<<"$banner"
num_lines=${#banner_lines[@]}
duration=5
interval=0.3
frames=$(echo "$duration / $interval" | bc)
for ((frame=0; frame<frames; frame++)); do
for ((i=0; i<num_lines; i++)); do
color_index=$(( (frame + i) % ${#colors[@]} ))
echo -ne "${colors[$color_index]}${banner_lines[i]}${RESET}\n"
done
sleep $interval
# Move cursor up to start of banner to overwrite in next frame
echo -ne "\033[${num_lines}A"
done
# Move cursor down to bottom of banner and clear screen after animation ends
echo -ne "\033[${num_lines}B"
echo -e """${BLUE}
###############################
# #
# CHECK WINE PREFIX #
# #
###############################
${RESET}"""
# Check if ~/.wine exists
if [ -d "$HOME/.wine" ]; then
echo -e "${GREEN}~/.wine exists.${RESET}"
else
echo -e "${RED}~/.wine doesn't exist.${RESET}"
exit 1
fi
# Check wine prefix architecture
explorer_metadata="$(file ~/.wine/drive_c/windows/explorer.exe)"
if echo "$explorer_metadata" | grep -q "x86-64"; then
linux_batch_arch="64"
echo -e "Wine prefix is 64-bit."
else
echo -e "Wine prefix is 32-bit."
fi
echo -e """${BLUE}
###############################
# #
# DOWNLOADING REACTOS ISO #
# #
###############################
${RESET}"""
iso_download="https://iso.reactos.org/livecd/reactos-livecd-0.4.16-dev-1481-ga753f34-x86-msvc-win-dbg.7z" # Default
if [ "$linux_batch_arch" = "64" ]; then
iso_download="https://iso.reactos.org/livecd/reactos-livecd-0.4.16-dev-1481-ga753f34-x64-msvc-win-dbg.7z"
iso32bit_isodownload="https://iso.reactos.org/livecd/reactos-livecd-0.4.16-dev-1481-ga753f34-x86-msvc-win-dbg.7z"
elif [ "$linux_batch_arch" = "32" ]; then
iso_download="https://iso.reactos.org/livecd/reactos-livecd-0.4.16-dev-1481-ga753f34-x86-msvc-win-dbg.7z"
fi
curl -# -o reactos.7z "$iso_download"
if [ "$linux_batch_arch" = "64" ]; then
curl -# -o reactos-32.7z "$iso32bit_isodownload"
fi
echo -e """${BLUE}
###############################
# #
# UNZIPPING REACTOS ISO #
# #
###############################
${RESET}"""
rm -rf ./reactos
rm -rf ./reactos-32
echo -e "${GREEN}Unzipping ReactOS 7-zip file...${RESET}"
7z x reactos.7z -oreactos > /dev/null
if [ "$linux_batch_arch" = "64" ]; then
7z x reactos-32.7z -oreactos-32 > /dev/null
fi
echo -e "${GREEN}Extracting ReactOS ISO...${RESET}"
7z x reactos/*.iso -oreactos/reactos > /dev/null
if [ "$linux_batch_arch" = "64" ]; then
7z x reactos-32/*.iso -oreactos-32/reactos > /dev/null
fi
echo -e "${GREEN}Cleaning up...${RESET}"
rm -rf reactos.7z
rm -rf reactos-32.7z
rm -rf reactos/*.iso
rm -rf reactos-32/*.iso
echo -e """${BLUE}
###############################
# #
# COPYING FILES #
# #
###############################
${RESET}"""
reactos_systemroot="./reactos/reactos/reactos"
reactos_systemroot_32="./reactos-32/reactos/reactos"
# Replace the broken cmd.exe with the ReactOS one
cp -f "$reactos_systemroot/system32/cmd.exe" "$HOME/.wine/drive_c/windows/system32/"
cp -f "$reactos_systemroot_32/system32/cmd.exe" "$HOME/.wine/drive_c/windows/syswow64/"
# Files to copy
files=(
"xcopy.exe"
"vbscript.dll"
"wscript.exe"
"timeout.exe"
"subst.exe"
"tree.com"
"sort.exe"
"findstr.exe"
"expand.exe"
"format.com"
"fsutil.exe"
"find.exe"
"hostname.exe"
"mshta.exe"
"ping.exe"
"choice.exe"
)
# Copy specific files to system32
for file in "${files[@]}"; do
cp -f "$reactos_systemroot/system32/$file" "$HOME/.wine/drive_c/windows/system32/"
done
# Copy all files from system32 individually
find "$reactos_systemroot/system32" -maxdepth 1 -type f | while read -r file; do
cp --update=none "$file" "$HOME/.wine/drive_c/windows/system32/"
done
# Copy all files from root of ReactOS dir individually
find "$reactos_systemroot" -maxdepth 1 -type f | while read -r file; do
cp --update=none "$file" "$HOME/.wine/drive_c/windows/"
done
# If 64-bit Wine prefix, copy 32-bit equivalents to syswow64
if [ "$linux_batch_arch" = "64" ]; then
for file in "${files[@]}"; do
cp -f "$reactos_systemroot_32/system32/$file" "$HOME/.wine/drive_c/windows/syswow64/"
done
find "$reactos_systemroot_32/system32" -maxdepth 1 -type f | while read -r file; do
cp --update=none "$file" "$HOME/.wine/drive_c/windows/syswow64/"
done
fi
echo -e """${BLUE}
###############################
# #
# SETTING UP WINDOWS PS #
# #
###############################
${RESET}"""
curl -# -o install_pwshwrapper.exe \
https://raw.githubusercontent.com/PietJankbal/powershell-wrapper-for-wine/master/install_pwshwrapper.exe
wine install_pwshwrapper.exe
wine powershell # Required to finish pwshwrapper setup
echo -e """${BLUE}
###############################
# #
# FINISHED #
# #
###############################
${RESET}"""