Initial Commit
[Projects.git] / pkgbuilds / wiifuse / src / wiifuse-0.2.0 / server / get_identity.sh
blob52337676f9e8ba7b5fa69882edcf0d32e91a1cbe
1 #!/bin/sh
3 DATADIR="/usr/local/etc/wiifuse"
5 PARTDIR="$1/.internals"
6 CERTSFILE="$PARTDIR/certs"
7 TMDFILE="$PARTDIR/tmd"
8 TICKETFILE="$PARTDIR/ticket"
10 META_ID="$1/crypto/title_id"
11 META_NAME="$1/header/name"
13 if [ -z "$1" -o ! -d "$PARTDIR" ]; then
14 echo "usage: $0 <mounted wiifuse partition directory> [name]"
15 exit 1
18 if [ ! -f "$CERTSFILE" -o ! -f "$TMDFILE" -o ! -f "$TICKETFILE" \
19 -o ! -f "$META_ID" -o ! -f "$META_NAME" ]; then
20 echo "error: directory $1 is not a mounted wiifuse partition"
21 exit 1
24 ID=`cat "$META_ID" | cut -d 'x' -f 2`
25 NAME=`cat "$META_NAME" | tr ' ' '_'`
27 echo "found '$NAME' ($ID)"
29 if [ ! -z "$2" ]; then
30 NAME="$2"
33 cp -vf "$CERTSFILE" "$DATADIR/$ID.certs"
34 cp -vf "$TMDFILE" "$DATADIR/$ID.tmd"
35 cp -vf "$TICKETFILE" "$DATADIR/$ID.tik"
37 cd "$DATADIR"
38 ln -vsf "$ID.certs" "$NAME.certs"
39 ln -vsf "$ID.tmd" "$NAME.tmd"
40 ln -vsf "$ID.tik" "$NAME.tik"
42 echo "done"