forked from cathery/sys-con
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathsys-con.sh
89 lines (78 loc) · 2.11 KB
/
sys-con.sh
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
#!/bin/bash
#
# This script is used to simplify nintendo switch developement
# You need homebrew ftpd installed
# Boot the switch, enter in ftpd, use this script to do basic actions:
# "ftp upload" to upload the binary (You just built) directly to the switch
# "ftp logs" to display the logs
# Same commands are available with "sd", usefull when the nintendo switch crash on boot (You plug the sdcard to your laptop and debug from there)
# IP of your switch on your network:
FTP_URL=ftp://192.168.10.238:5000
#Below variable need to stay unchanged, they are correct whatever the developer
NSP_FILE=./out/atmosphere/contents/690000000000000D/exefs.nsp
DST_NSP_FILE=atmosphere/contents/690000000000000D/exefs.nsp
NRO_FILE=./out/switch/sys-con.nro
DST_NRO_FILE=switch/sys-con.nro
LOG_FILE=config/sys-con/log.txt
usage () {
echo "Usage: "
echo " $0 ftp upload"
echo " $0 ftp logs"
echo " $0 sd upload"
echo " $0 sd logs"
echo " $0 build"
exit 1
}
display_logs () {
BLUE='\033[0;34m'
RED='\033[0;31m'
YELLOW='\033[0;33m'
NC='\033[0m'
echo "---- LOGS ----"
while IFS= read -r line
do
if [[ $line == "|I|"* ]]; then
echo -e "${BLUE}${line}${NC}"
elif [[ $line == "|E|"* ]]; then
echo -e "${RED}${line}${NC}"
elif [[ $line == "|W|"* ]]; then
echo -e "${YELLOW}${line}${NC}"
else
echo "$line"
fi
done < ./log.txt
echo "---- END ----"
}
if [ "$1" == "ftp" ]; then
if [ "$2" == "upload" ]; then
echo "FTP upload"
curl -T $NSP_FILE "$FTP_URL/$DST_NSP_FILE" || exit 1
curl -T $NRO_FILE "$FTP_URL/$DST_NRO_FILE" || exit 1
exit 0
fi
if [ "$2" == "logs" ]; then
curl "$FTP_URL/$LOG_FILE" -o ./log.txt || exit 1
display_logs
exit 0
fi
fi
if [ "$1" == "sd" ]; then
if [ "$2" == "upload" ]; then
echo "SD card copy"
cp $NSP_FILE /d/$DST_NSP_FILE || exit 1
sync
echo "OK"
exit 0
fi
if [ "$2" == "logs" ]; then
cp /d/$LOG_FILE ./log.txt || exit 1
display_logs
exit 0
fi
fi
if [ "$1" == "build" ]; then
rm *.zip
make distclean || exit 1
exit 0
fi
usage