forked from batari-Basic/batari-Basic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install_ux.sh
executable file
·78 lines (55 loc) · 2 KB
/
install_ux.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
#!/bin/sh
OS=$(uname -s)
if [ ! "$OS" = Linux -a ! "$OS" = Darwin ] ; then
echo "##### WARNING: Unsupport \"$OS\" OS. You may need to create"
echo "##### your own bB binaries."
fi
if [ "$(uname -s)" = Linux ] ; then
PROFILE=~/.bashrc
else
PROFILE=~/.profile
fi
# need to test for these, because if they exist than bash won't read .profile
for PRO in ~/.bash_profile ~/.bash_login ~/.bashrc ; do
[ -r "$PRO" ] && PROFILE="$PRO"
done
bB=$PWD
cat <<EOF
__________________________The_bB_Unix_Installer_v1__________________________
This script will update your $PROFILE file to
set the following variables each time you open a terminal window.
export bB="$bB"
export PATH=\$PATH:\$bB
You may run this script as many times as you like, and should do so if you're
installing a new version of bB, or if you relocate this bB directory.
Hit [ENTER] to begin, or type Q and [ENTER] to quit.
EOF
read ANSWER
[ "$ANSWER" ] && exit 1
# ensure the profile exists
[ -r "$PROFILE" ] || touch "$PROFILE"
# create a backup of the profile...
cp "$PROFILE" "$PROFILE.$(date +%y%m%d%H%M%S)"
# remove any old bB entries
grep -v bB "$PROFILE" > "$PROFILE.new"
echo "##### bB variables, added by installer on $(date +%y/%m/%d)" >> "$PROFILE.new"
echo "export bB=\"$bB\"" >> "$PROFILE.new"
echo 'export PATH=$PATH:$bB' >> "$PROFILE.new"
if [ ! -r "$PROFILE.new" ] ; then
echo
echo "Could not create the new profile. Is the filesystem full?"
echo "Exiting..."
exit 2
fi
# move the contents instead, to preserve any custom permissions on the profile
cat "$PROFILE.new" > "$PROFILE" && rm "$PROFILE.new"
cat <<EOF
$PROFILE has been updated successfully.
To test the new setup...
1. open another terminal window.
(the bB and PATH variables will now be active in any new terminal window)
2. type: cd "\$bB/samples"
3. type: 2600basic.sh zombie_chase.bas
This should create a zombie_chase.bas.bin binary file in the samples directory
that will work on real hardware, in stella, or any other emulator.
EOF