7 if [ "$can_ask" = "y" ]; then
9 echo -n "Press enter to continue..."
16 # Make sure we have a terminal to talk to
24 echo 'No user input available'
28 GUESS_XTERMS="x-terminal-emulator xterm rxvt roxterm gnome-terminal dtterm eterm Eterm kvt konsole aterm"
29 for a in $GUESS_XTERMS; do
30 if type $a >/dev/null 2>&1; then
37 echo 'No terminal emulator available'
41 exec "$XTERM" -e "sh '$0'"
49 # Make sure we can run java
52 echo -n "Checking for java..."
54 if java -version > /dev/null 2>&1; then
57 echo " java isn't working."
59 echo "You'll need to install a java runtime system"
60 echo "on this computer before AltOS will work properly."
65 # Pick an installation target
68 if [ '(' -d /opt -a -w /opt ')' -o '(' -d /opt/AltOS -a -w /opt/AltOS ')' ]; then
71 target_default="$HOME"
76 echo -n "Installation location [default: $target_default] "
77 if [ "$can_ask" = "y" ]; then
85 target="$target_default"
94 target_altos="$target"/AltOS
96 echo -n "Installing to $target..."
99 # Make sure the target exists
101 mkdir -p "$target_altos"
103 if [ ! -d "$target_altos" ]; then
104 echo "$target_altos does not exist and cannot be created"
108 if [ ! -w "$target_altos" ]; then
109 echo "$target_altos cannot be written"
114 # Unpack the tar archive appended to the end of this script
116 archive_line=`awk '/^__ARCHIVE_BELOW__/ {print NR + 1; exit 0; }' "$0"`
118 tail -n+$archive_line "$0" | tar xjf - -C "$target"
125 echo "Install failed."
131 # Create the .desktop file by editing the paths
138 target_abs=`pwd`/$target
142 BIN="$target_abs"/AltOS
144 desktop="$target"/AltOS/altos.desktop
147 sed "s;%BIN%;$BIN;" "$target"/AltOS/altos.desktop.in > "$desktop"
150 # Figure out where to install the .desktop file. If we can, write it
151 # to the public /usr/share/applications, otherwise, write it to the
152 # per-user ~/.local/share/applications
155 public=/usr/share/applications
156 private=$HOME/.local/share/applications
159 if [ -d "$public" -a -w "$public" ]; then
162 mkdir -p "$private" >/dev/null 2>&1
163 if [ -d "$private" -a -w "$private" ]; then
170 echo "Cannot install application icon"
175 echo -n "Installing .desktop file to $apps..."
177 cp "$desktop" "$apps"