File: edit-ns-preferences

package info (click to toggle)
netenv 0.94.3-21
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 444 kB
  • ctags: 66
  • sloc: sh: 879; ansic: 136; makefile: 30
file content (59 lines) | stat: -rwxr-xr-x 1,931 bytes parent folder | download | duplicates (5)
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
#!/bin/sh
#******************************************************************
# edit-ns-preferences Time-stamp: <01/02/10 14:52:35 bav>
#******************************************************************
#                            Gerd Bavendiek  bav@epost.de  99-09-03
#
# Tiny hack for editing Netscape's preferences. Takes one of
# 1 manual
# 2 automatic
# 3 direct
# as an argument.
#-------------------------------------------------------------------

# Check argument 
case $1 in
   1|2|3 )
      TMPFIL=/tmp/.edit-ns-preferences.$$
      cp -p ~/.netscape/preferences.js ~/.netscape/preferences.js.pre
   ;;
   *)
      echo -e $0: 'Usage: edit-ns-preferences [1|2|3]\nwherein 1 is manual, 2 automatic and 3 direct'
      exit 1
   ;;
esac

# If network.proxy.type _not_ defined, put it in.
if grep ^user_pref\(\"network.proxy.type ~/.netscape/preferences.js > /dev/null; then
   # it's defined

    awk -v NETSCAPE_PROXY_TYPE=$1 '/^user_pref\(\"network.proxy.type\"\,/ {printf "%s %d);\n", $1, NETSCAPE_PROXY_TYPE; next}
{print $0}' ~/.netscape/preferences.js > $TMPFIL
else
   # not yet defined
    awk -v NETSCAPE_PROXY_TYPE=$1 '/^user_pref\(\"network.proxy.no_proxies_on\"\,/ {printf "%s\nuser_pref\(\"network.proxy.type\", %d);\n", $0, NETSCAPE_PROXY_TYPE; next}
{print $0}' ~/.netscape/preferences.js > $TMPFIL

fi

mv $TMPFIL ~/.netscape/preferences.js

exit 0


#  3) echo direkt
#  # wenn was drinsteht, rausschmeissen. wenn nicht, dann nicht.
#    awk '/^user_pref\(\"network.proxy.type\"\,/ {next}
# {print $0}' ~/.netscape/preferences.js > $TMPFIL
 


exit 0

   # The following line count shall make things a little bit saver
   if [ `cat ~/.netscape/preferences.js | wc -l` -ne `cat $TMPFIL | wc -l` ]; then
      echo $0: Error in editing ~/.netscape/preferences.js: linecount does not match
   else
      echo $0: ~/.netscape/preferences.js has been edited !
      mv $TMPFIL ~/.netscape/preferences
   fi