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 for infile in "$target"/AltOS/*.desktop.in; do
145 desktop="$target"/AltOS/`basename "$infile" .in`
147 sed -e "s;%bindir%;$BIN;" -e "s;%icondir%;$BIN;" "$infile" > "$desktop"
152 # Figure out where to install the .desktop files. If we can, write it
153 # to the public /usr/share/applications, otherwise, write it to the
154 # per-user ~/.local/share/applications
157 public=/usr/share/applications
158 private=$HOME/.local/share/applications
161 if [ -d "$public" -a -w "$public" ]; then
164 mkdir -p "$private" >/dev/null 2>&1
165 if [ -d "$private" -a -w "$private" ]; then
172 echo "Cannot install application icon"
177 echo -n "Installing .desktop files to $apps..."
179 cp "$target"/AltOS/*.desktop "$apps"
191 # Install icon to desktop if desired
194 if [ -d $HOME/Desktop ]; then
196 if [ "$can_ask" = "y" ]; then
203 while [ "$answered" = "n" ]; do
204 echo -n "Install icons to desktop? [default: $default_desktop] "
205 if [ "$can_ask" = "y" ]; then
212 case "$do_desktop" in
214 do_desktop=$default_desktop
218 case "$do_desktop" in
225 echo -n "Installing desktop icons..."
226 case "$do_desktop" in
228 for d in "$target"/AltOS/*.desktop; do
229 ln -f -s "$d" "$HOME/Desktop/"