Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.debian.user > #215340 > unrolled thread

Treate .sh and .bash the same way Apache2

Started byjohn doe <johndoe65534@mail.com>
First post2019-10-22 16:10 +0200
Last post2019-10-23 07:30 +0200
Articles 7 — 3 participants

Back to article view | Back to linux.debian.user


Contents

  Treate .sh and .bash the same way Apache2 john doe <johndoe65534@mail.com> - 2019-10-22 16:10 +0200
    Re: Treate .sh and .bash the same way Apache2 Dan Ritter <dsr@randomstring.org> - 2019-10-22 16:30 +0200
      Re: Treate .sh and .bash the same way Apache2 john doe <johndoe65534@mail.com> - 2019-10-22 16:30 +0200
        Re: Treate .sh and .bash the same way Apache2 Dan Ritter <dsr@randomstring.org> - 2019-10-22 17:20 +0200
          Re: Treate .sh and .bash the same way Apache2 john doe <johndoe65534@mail.com> - 2019-10-22 18:00 +0200
            Re: Treate .sh and .bash the same way Apache2 Kushal Kumaran <kushal@locationd.net> - 2019-10-23 04:00 +0200
              Re: Treate .sh and .bash the same way Apache2 john doe <johndoe65534@mail.com> - 2019-10-23 07:30 +0200

#215340 — Treate .sh and .bash the same way Apache2

Fromjohn doe <johndoe65534@mail.com>
Date2019-10-22 16:10 +0200
SubjectTreate .sh and .bash the same way Apache2
Message-ID<yU31f-Fv-3@gated-at.bofh.it>
Hi,

I'm using Apache2 on Debian (Stretch 9) and trying to have the .bash
extension treated like the .sh extension:

For now, I have modified the file
/etc/apache2/mods-availables/autoindex.conf byt adding .bash to the
following line:

        AddIcon /icons/script.gif .conf .sh .shar .csh .ksh .tcl .bash


The file with the .bash extension is not treated like it is for .sh
(everything is working fine for the .sh), what am I missing?


In other words, how should Apache2 be configured to make no difference
between .sh and .bash extension.

Any help is welcome.

--
John Doe

[toc] | [next] | [standalone]


#215341

FromDan Ritter <dsr@randomstring.org>
Date2019-10-22 16:30 +0200
Message-ID<yU3kB-Mg-1@gated-at.bofh.it>
In reply to#215340
john doe wrote: 
> 
> Hi,
> 
> I'm using Apache2 on Debian (Stretch 9) and trying to have the .bash
> extension treated like the .sh extension:
> 
> For now, I have modified the file
> /etc/apache2/mods-availables/autoindex.conf byt adding .bash to the
> following line:
> 
>         AddIcon /icons/script.gif .conf .sh .shar .csh .ksh .tcl .bash
> 
> 
> The file with the .bash extension is not treated like it is for .sh
> (everything is working fine for the .sh), what am I missing?
> 
> 
> In other words, how should Apache2 be configured to make no difference
> between .sh and .bash extension.

You say "treated like" but the config you have is just for what
icons are shown in file listings.

Is that what's going wrong?

-dsr-

[toc] | [prev] | [next] | [standalone]


#215342

Fromjohn doe <johndoe65534@mail.com>
Date2019-10-22 16:30 +0200
Message-ID<yU3kB-Mg-3@gated-at.bofh.it>
In reply to#215341
On 10/22/2019 4:20 PM, Dan Ritter wrote:
> john doe wrote:
>>
>> Hi,
>>
>> I'm using Apache2 on Debian (Stretch 9) and trying to have the .bash
>> extension treated like the .sh extension:
>>
>> For now, I have modified the file
>> /etc/apache2/mods-availables/autoindex.conf byt adding .bash to the
>> following line:
>>
>>         AddIcon /icons/script.gif .conf .sh .shar .csh .ksh .tcl .bash
>>
>>
>> The file with the .bash extension is not treated like it is for .sh
>> (everything is working fine for the .sh), what am I missing?
>>
>>
>> In other words, how should Apache2 be configured to make no difference
>> between .sh and .bash extension.
>
> You say "treated like" but the config you have is just for what
> icons are shown in file listings.
>
> Is that what's going wrong?
>

Yes, along with that if I click on a .sh file I get prompted to
download/open the file but if I click on a .bash file I can read the
file in the browser.

--
John Doe

[toc] | [prev] | [next] | [standalone]


#215344

FromDan Ritter <dsr@randomstring.org>
Date2019-10-22 17:20 +0200
Message-ID<yU470-1jr-9@gated-at.bofh.it>
In reply to#215342
john doe wrote: 
> On 10/22/2019 4:20 PM, Dan Ritter wrote:
> > john doe wrote:
> >>
> >> Hi,
> >>
> >> I'm using Apache2 on Debian (Stretch 9) and trying to have the .bash
> >> extension treated like the .sh extension:
> >>
> >> For now, I have modified the file
> >> /etc/apache2/mods-availables/autoindex.conf byt adding .bash to the
> >> following line:
> >>
> >>         AddIcon /icons/script.gif .conf .sh .shar .csh .ksh .tcl .bash
> >>
> >>
> >> The file with the .bash extension is not treated like it is for .sh
> >> (everything is working fine for the .sh), what am I missing?
> >>
> >>
> >> In other words, how should Apache2 be configured to make no difference
> >> between .sh and .bash extension.
> >
> > You say "treated like" but the config you have is just for what
> > icons are shown in file listings.
> >
> > Is that what's going wrong?
> >
> 
> Yes, along with that if I click on a .sh file I get prompted to
> download/open the file but if I click on a .bash file I can read the
> file in the browser.

Right, that's a completely separate thing.

The config you want is something like:

/etc/mime.types:
application/x-shellscript       .sh .shar .bash

and then run
 a2enmod mime

And if you haven't enabled autoindex.conf,

 a2enmod autoindex


-dsr-

[toc] | [prev] | [next] | [standalone]


#215345

Fromjohn doe <johndoe65534@mail.com>
Date2019-10-22 18:00 +0200
Message-ID<yU4JH-1xj-5@gated-at.bofh.it>
In reply to#215344
On 10/22/2019 5:13 PM, Dan Ritter wrote:
> john doe wrote:
>> On 10/22/2019 4:20 PM, Dan Ritter wrote:
>>> john doe wrote:
>>>>
>>>> Hi,
>>>>
>>>> I'm using Apache2 on Debian (Stretch 9) and trying to have the .bash
>>>> extension treated like the .sh extension:
>>>>
>>>> For now, I have modified the file
>>>> /etc/apache2/mods-availables/autoindex.conf byt adding .bash to the
>>>> following line:
>>>>
>>>>         AddIcon /icons/script.gif .conf .sh .shar .csh .ksh .tcl .bash
>>>>
>>>>
>>>> The file with the .bash extension is not treated like it is for .sh
>>>> (everything is working fine for the .sh), what am I missing?
>>>>
>>>>
>>>> In other words, how should Apache2 be configured to make no difference
>>>> between .sh and .bash extension.
>>>
>>> You say "treated like" but the config you have is just for what
>>> icons are shown in file listings.
>>>
>>> Is that what's going wrong?
>>>
>>
>> Yes, along with that if I click on a .sh file I get prompted to
>> download/open the file but if I click on a .bash file I can read the
>> file in the browser.
>
> Right, that's a completely separate thing.
>
> The config you want is something like:
>
> /etc/mime.types:
> application/x-shellscript       .sh .shar .bash
>
> and then run
>  a2enmod mime
>
> And if you haven't enabled autoindex.conf,
>
>  a2enmod autoindex
>

Following the line for sh in the instructed file:

text/x-sh     sh

I went for:

text/x-bash     bash


I just saw your answer, the following in
'/etc/apache2/mods-available/autoindex.conf' does it as well:

AddType text/plain .bash


Next step is to figure out how to do the same for file that don't have
an extension that I can use but they always start with the same pattern:

xxx.abc
xxx.def
xxx.ghi

Thanks for the help DSR, you got me rolling! :)

--
John Doe

[toc] | [prev] | [next] | [standalone]


#215365

FromKushal Kumaran <kushal@locationd.net>
Date2019-10-23 04:00 +0200
Message-ID<yUe6l-7oI-1@gated-at.bofh.it>
In reply to#215345
john doe <johndoe65534@mail.com> writes:

> <snip>
>
> Next step is to figure out how to do the same for file that don't have
> an extension that I can use but they always start with the same pattern:
>
> xxx.abc
> xxx.def
> xxx.ghi
>

https://httpd.apache.org/docs/2.4/mod/mod_mime_magic.html

Note the caution about potential performance issues.

> Thanks for the help DSR, you got me rolling! :)
>

-- 
regards,
kushal

[toc] | [prev] | [next] | [standalone]


#215367

Fromjohn doe <johndoe65534@mail.com>
Date2019-10-23 07:30 +0200
Message-ID<yUhnA-1fw-5@gated-at.bofh.it>
In reply to#215365
On 10/23/2019 3:51 AM, Kushal Kumaran wrote:
> john doe <johndoe65534@mail.com> writes:
>
>> <snip>
>>
>> Next step is to figure out how to do the same for file that don't have
>> an extension that I can use but they always start with the same pattern:
>>
>> xxx.abc
>> xxx.def
>> xxx.ghi
>>
>
> https://httpd.apache.org/docs/2.4/mod/mod_mime_magic.html
>
> Note the caution about potential performance issues.
>

Thanks for this, the following looks to do it as well:

        <FilesMatch "^<START-OF-FILE>*">
                ForceType text/plain
                Header set Content-Disposition attachment
        </FilesMatch>

--
John Doe

[toc] | [prev] | [standalone]


Back to top | Article view | linux.debian.user


csiph-web