3 # Ensure we have something to scan
6 echo "Usage: $0 floppy-to-test.adf"
7 echo "Usage: $0 directory-to-scan"
12 # Ensure we have all native tools
13 if [ -z "$(which curl)" -o \
14 -z "$(which lha)" -o \
15 -z "$(which fs-uae)" -o \
16 -z "$(which sha256sum)" ]
18 echo -e "\033[1m\033[31mERROR:\033[0m"
19 echo "This script requires the following programs to be in $PATH:"
30 INSTALLERS="$CWD/installers"
35 CURL="curl --progress-bar --location -o"
40 # Provide a way to bail.
41 # This does NOT clean up a running emulation session.
53 echo -en "\033[1m\033[3$1m"
62 # Download any packages we don't have yet
63 function download_installers()
65 colorprint 3 "Downloading missing components..."
67 mkdir -p "$INSTALLERS"
69 for n in $(cat installer_urls)
72 TXTNAME=${LHANAME%.lha}.readme
74 if [ ! -e "$INSTALLERS/$LHANAME" ]
76 echo -e "\033[1m\033[34mDownloading\033[0m $LHANAME ..."
77 $CURL "$INSTALLERS/$LHANAME" "$n"
80 if [ ! -e "$INSTALLERS/$TXTNAME" ]
82 echo -e "\033[1m\033[34mDownloading\033[0m $TXTNAME ..."
83 $CURL "$INSTALLERS/$TXTNAME" "${n%.lha}.readme"
87 colorprint 2 "...done"
93 # Checksum all files we get from Aminet
94 function verify_installers()
96 colorprint 3 "Checking integrity..."
98 if ! sha256sum --strict --quiet --check sha256sums
101 echo -e "\033[1m\033[31mERROR:\033[0m"
102 echo "Integrity check failed."
103 echo "Try removing the broken file and re-downloading it."
104 echo "If you just downloaded these files, then maybe Aminet is currently having problems serving those files?"
109 colorprint 2 "...done"
115 # This prepares a folder to be a virtual partition,
116 # with an Amiga system ready to run and scan a directory.
117 function populate_dh0()
119 mkdir -p "$TD/$DHDIR"
123 mkdir -p "$TD/$DHDIR/C"
124 lha xqiw="$TD/$DHDIR/C" "$INSTALLERS"/CheckX.lha CheckX/CheckX
125 lha xqiw="$TD/$DHDIR/C" "$INSTALLERS"/UAEquit.lha UAEquit
129 mkdir -p "$TD/$DHDIR/Libs"
131 mkdir -p "$TD/$DHDIR/Libs/xad"
132 lha xqiw="$TD/$DHDIR/Libs" "$INSTALLERS"/xadmaster000.lha xad/Libs/xadmaster.library
133 lha xqiw="$TD/$DHDIR/Libs/xad" "$INSTALLERS"/xadmaster000.lha xad/Libs/xad/*
135 mkdir -p "$TD/$DHDIR/Libs/xfd"
136 lha xqiw="$TD/$DHDIR/Libs" "$INSTALLERS"/xfdmaster.lha xfd_User/Libs/xfdmaster.library
137 lha xqiw="$TD/$DHDIR/Libs/xfd" "$INSTALLERS"/xfdmaster.lha xfd_User/Libs/xfd/*
139 lha xqiw="$TD/$DHDIR/Libs" "$INSTALLERS"/xvslibrary.lha xvs/libs/xvs.library
142 # Startup-sequence, config, registration keys
143 mkdir -p "$TD/$DHDIR/S"
144 lha xqiw="$TD/$DHDIR/S" "$INSTALLERS"/xadmaster-key.lha xadmaster.key
146 cat > "$TD/$DHDIR/S/startup-sequence" <<-EOF
147 CheckX ALL FROM SYS:scandir LOG SYS:checkx-scandir.log
154 function write_uae_config()
156 # Write main UAE config
157 cat > "$TD/amiga-virus-scan.fs-uae" <<-EOF
160 automatic_input_grab = 0
162 expect_version = 2.8.0
164 #floppy_drive_1 = ./df1.adf
166 hard_drive_0 = ./$DHDIR
167 initial_input_grab = 0
169 joystick_port_0 = Mouse
170 joystick_port_0_mode = mouse
171 joystick_port_1 = none
172 joystick_port_1_mode = nothing
173 joystick_port_2 = none
174 joystick_port_2_mode = none
175 joystick_port_3 = none
176 joystick_port_3_mode = none
180 uae_sound_output = none
187 # Prevent FS-UAE from printing audio errors
188 cat > "$TD"/.alsoftrc <<-EOF
202 colorprint 7 " *******************************************"
203 colorprint 7 " Amiga virus scanner wrapper starting up"
204 colorprint 7 " *******************************************"
208 # Get external Amiga software
213 # Prepare emulation environment
214 colorprint 3 "Preparing emulation environment..."
216 TD="$(mktemp --directory)"
221 colorprint 7 "Scan target: $1 (will be copied to emulation first)"
223 cp -r "$1" "$TD/$DHDIR/scandir"
224 chmod -R u+rwX "$TD/$DHDIR/scandir"
226 colorprint 2 "...done"
231 colorprint 3 "Running emulator..."
234 fs-uae amiga-virus-scan.fs-uae > /dev/null
236 colorprint 2 "...done"
243 colorprint 2 "Scan results:"
245 cat ./dh0/checkx-scandir.log