-
Notifications
You must be signed in to change notification settings - Fork 12
/
iso2ps2
executable file
·118 lines (99 loc) · 3.36 KB
/
iso2ps2
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
#!/bin/bash
#
# iso2ps2 - copy Playstation 2 ISO games to PS2 HDD via network
#
# Copyright (C) 2012 Rodrigo Silva (MestreLion) <linux@rodrigosilva.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. See <http://www.gnu.org/licenses/gpl.html>
#
ip=10.10.10.10
ps2dir="/dados/Playstation"
hdldump="$ps2dir/PC Tools/HDL Dumx 0.8.6/hdl_dump.exe"
isodir="$ps2dir/ISO/PS2"
iso=
name=
startup=
flags=
myname="${0##*/}"
mydir=$(dirname "$(readlink -f "$0")")
verbose=1
fatal() { printf "%s: error: %s\n" "$myname" "$1" >&2 ; exit "${2:-1}" ; }
fatal() { [[ "$1" ]] && printf "%s: error: %s\n" "$myname" "$1" >&2 ; exit "${2:-1}" ; }
fatal() { [[ "$1" ]] && echo "$myname: error: $1" >&2 ; exit ${2:-1} ; }
message() { ((verbose)) && printf "%s\n" "$1"; }
integer() { [[ "$1" != *[!0-9]* ]] || argerr "'$1'${2:+ in $2} is not an integer." ; }
message() { printf "%s\n" "$1" >&2 ; }
fatal() { [[ "$1" ]] && message "$myname: error: $1" ; exit ${2:-1} ; }
skip() { i=${2:-$file}; message "skipping${i:+ $i}${1:+: $1}"; continue ; }
argerr() { printf "%s: %s\n" "$myname" "${1:-error}" >&2 ; usage 1 ; }
invalid() { argerr "invalid option: $1" ; }
missing() { argerr "missing${1:+ $1} operand." ; }
missing() { argerr "missing ${2:+$2 }operand${1:+ from $1}." ; }
quit() { message "Goodbye!" ; exit; }
relpath() { python -c "import os.path; print os.path.relpath('$1'${2:+,'$2'})";}
usage() {
cat <<-USAGE
Usage: $myname [options]
USAGE
if [[ "$1" ]] ; then
cat >&2 <<- USAGE
Try '$myname --help' for more information.
USAGE
exit 1
fi
cat <<-USAGE
Short description
Options:
-h|--help - show this page.
-v|--verbose - print more details about what is being done.
Copyright (C) 2012 Rodrigo Silva (MestreLion) <linux@rodrigosilva.com>
License: GPLv3 or later. See <http://www.gnu.org/licenses/gpl.html>
USAGE
exit 0
}
# Option handling
files=()
for arg in "$@"; do [[ "$arg" == "-h" || "$arg" == "--help" ]] && usage ; done
while (( $# )); do
case "$1" in
-v|--verbose ) verbose=1 ;;
--var=* ) var="${1#*=}" ;;
--var ) shift ; var="$1" ;;
-- ) shift ; break ;;
-* ) invalid "$1" ;;
* ) files+=( "$1" ) ;;
esac
shift
done
files+=( "$@" )
#[[ "$var" ]] || missing "--var" "ARG"
[[ "$iso" ]] || {
cd "$isodir"
shopt -s nullglob
options=( *.[Ii][Ss][Oo] )
shopt -u nullglob
message "Available ISOs:"
PS3="Choose an install (0 to quit): "
select iso in "${options[@]}"; do
((REPLY==0)) && quit
[[ "$iso" ]] && break
done
iso="${isodir}/${iso}"
cd - >/dev/null
read -r code name size < <(wine "$hdldump" cdvd_info "$iso")
name=${name//\"/}
code=${code//\"/}
size=${size:0:-3}
}
wine "$hdldump" inject_dvd "$ip" "$name" "$iso" "$code"