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
139 target_abs=`pwd`/$target
143 BIN="$target_abs"/AltOS
145 for infile in "$target"/AltOS/*.desktop.in; do
146 desktop="$target"/AltOS/`basename "$infile" .in`
148 sed -e "s;%bindir%;$BIN;" -e "s;%icondir%;$BIN;" "$infile" > "$desktop"
153 # Install the .desktop file
156 for desktop in "$target"/AltOS/*.desktop; do
159 xdg-desktop-menu install --mode system "$desktop"
162 xdg-desktop-menu install --mode user "$desktop"
168 # Install mime type file
171 for mimetype in "$target"/AltOS/*-mimetypes.xml; do
174 xdg-mime install --mode system "$mimetype"
177 xdg-mime install --mode user "$mimetype"
186 for icon_dir in /usr/share/icons/hicolor/scalable/mimetypes "$HOME/.icons" "$HOME/.kde/share/icons"; do
187 if [ -w "$icon_dir" ]; then
188 cp "$target"/AltOS/*.svg "$icon_dir"
189 update-icon-caches "$icon_dir"
195 # Install icon to desktop if desired
198 if [ -d $HOME/Desktop ]; then
200 if [ "$can_ask" = "y" ]; then
207 while [ "$answered" = "n" ]; do
208 echo -n "Install icons to desktop? [default: $default_desktop] "
209 if [ "$can_ask" = "y" ]; then
216 case "$do_desktop" in
218 do_desktop=$default_desktop
222 case "$do_desktop" in
229 case "$do_desktop" in
231 echo -n "Installing desktop icons..."
232 for d in "$target"/AltOS/*.desktop; do
234 cp --remove-destination "$d" "$HOME/Desktop/"