Sponsored Content
Top Forums Shell Programming and Scripting Compact script with array - Good idea? Post 302676297 by Corona688 on Tuesday 24th of July 2012 11:16:16 AM
Old 07-24-2012
It looks pretty, but I wouldn't call it organized. You've got lots of data duplication -- why bother storing nginx in an array named nginx -- and if both things get the same prefix and make options, why not split that out too? And you're not looping things you can loop. And you're desperately avoiding splitting when it's something that could replace 80% of your code here. And using arrays means you end up spitting out ${ARR[1]} and ${ARR[2]} everywhere instead of using meaningful variable names. Why is '-j 4' the third element of your array and not the second, fifth, ninth? Only the original programmer knows.

In short this code will be as hard for you to read later as it was for me to read now. Smilie

I'd still split the URL's out since they're big and unwieldy.

Code:
MAKE_OPTS="-j 4"
CONFIG_OPTS="--prefix=/opt"

nginx="http://nginx.org/download/nginx-1.2.2.tar.gz"
supervisor="http://pypi.python.org/packages/source/s/supervisor/supervisor-3.0a12.tar.gz"

for PACKAGE in nginx supervisor
do
        echo wget "${!PACKAGE}"
        echo configure $CONFIG_OPTS ... # Note not quoted
        echo make $MAKE_OPTS ... # Note not quoted
done

I suppose you could have variables overriding the default $CONFIG_OPTS and $MAKE_OPTS for a particular package. If they're blank, use the default options, if they're not, use them instead.

Last edited by Corona688; 07-24-2012 at 12:22 PM..
 

8 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Dual Boot a good idea?

I was just wondering if it would be alright to dual boot a machine with both UNIX using XTERM for the interface and windows 98 or if people consider this a bad idea? if you consider it bad do tell me some possible alternatives..also would it be better to get linux over pure unix? I'd like a visual... (8 Replies)
Discussion started by: PravusMentis
8 Replies

2. Shell Programming and Scripting

Limitations of awk? Good idea? Bad idea?

Keeping in mind that I'm relatively comfortable with programming in general but very new to unix and korn/bourne shell scripts.. I'm using awk on a CSV file, and then performing calculations and operations on specific fields within specific records. The CSV file I'm working with has about 600... (2 Replies)
Discussion started by: yongho
2 Replies

3. Shell Programming and Scripting

any good idea on this?

txt file like this, 1 2 3 4456 a bb c d 3 f e 1 k 32 d m f e 123 m 2 k every line contains 3 or more columns, all the columns are separated by space, and every column includes 1 to 3 character. what I wanna do is deleting the first three columns, and keep the rest no matter how long... (7 Replies)
Discussion started by: fedora
7 Replies

4. Shell Programming and Scripting

Script Idea's / Help

Hi there, I'm pretty new to scripting and wondering if anyone had any idea's, scripts or snippets on how I can do the following. I basically want a shell script that will look at all the files in a directory and find all the names and addresses in them then output them to the screen nicely... (12 Replies)
Discussion started by: mrpugster
12 Replies

5. Shell Programming and Scripting

Script to compact information !

Hello Group, Could you please help me with a shell script that condense in this case each 12 rows of hour information in only one row per day as following: Final Fields in each row 1.Ticker Name 2. D (Daily) 3. Date 4. Open Price (The open price of the first record of the day) 5. High... (13 Replies)
Discussion started by: csierra
13 Replies

6. Shell Programming and Scripting

Help with the idea of a script to modify time

Hello friends, I need an idea or a ready solution for a problem i have the following lines in text file: 1 20100920140122 object4 MOVE IN 2 20100920150012 object4 MOVE OUT -- cut -- the second column is the date and time: 20100920140122 = 2010 09 20 14:01.22 what I need to do is to add 40... (8 Replies)
Discussion started by: peetteerr
8 Replies

7. UNIX for Advanced & Expert Users

echo 1 > /proc/sys/vm/drop_caches a good idea?

Hi folks. I work with several production servers, and I have seen in some Kernel Cache using most of the memory. See this pic: http://i51.tinypic.com/301nb6c.jpg Do you think this is a smart choice? Remember these are productions servers and it is extremely necesary this does not... (6 Replies)
Discussion started by: erick_tuk
6 Replies

8. Shell Programming and Scripting

need a new idea for a script

Hi all, I now have project in UNIX Solaris and I want to have some new ideas to execute it, so I hope you help me finding new ideas in scripting or some infrastructure .bye (1 Reply)
Discussion started by: hard_revenge
1 Replies
SYSTEMD-SOCKET-PROXYD(8)				       systemd-socket-proxyd					  SYSTEMD-SOCKET-PROXYD(8)

NAME
systemd-socket-proxyd - Bidirectionally proxy local sockets to another (possibly remote) socket. SYNOPSIS
systemd-socket-proxyd [OPTIONS...] HOST:PORT systemd-socket-proxyd [OPTIONS...] UNIX-DOMAIN-SOCKET-PATH DESCRIPTION
systemd-socket-proxyd is a generic socket-activated network socket forwarder proxy daemon for IPv4, IPv6 and UNIX stream sockets. It may be used to bi-directionally forward traffic from a local listening socket to a local or remote destination socket. One use of this tool is to provide socket activation support for services that do not natively support socket activation. On behalf of the service to activate, the proxy inherits the socket from systemd, accepts each client connection, opens a connection to a configured server for each client, and then bidirectionally forwards data between the two. This utility's behavior is similar to socat(1). The main differences for systemd-socket-proxyd are support for socket activation with "Accept=false" and an event-driven design that scales better with the number of connections. OPTIONS
The following options are understood: -h, --help Print a short help text and exit. --version Print a short version string and exit. --connections-max=, -c Sets the maximum number of simultaneous connections, defaults to 256. If the limit of concurrent connections is reached further connections will be refused. EXIT STATUS
On success, 0 is returned, a non-zero failure code otherwise. EXAMPLES
Simple Example Use two services with a dependency and no namespace isolation. Example 1. proxy-to-nginx.socket [Socket] ListenStream=80 [Install] WantedBy=sockets.target Example 2. proxy-to-nginx.service [Unit] Requires=nginx.service After=nginx.service Requires=proxy-to-nginx.socket After=proxy-to-nginx.socket [Service] ExecStart=/lib/systemd/systemd-socket-proxyd /tmp/nginx.sock PrivateTmp=yes PrivateNetwork=yes Example 3. nginx.conf [...] server { listen unix:/tmp/nginx.sock; [...] Example 4. Enabling the proxy # systemctl enable --now proxy-to-nginx.socket $ curl http://localhost:80/ Namespace Example Similar as above, but runs the socket proxy and the main service in the same private namespace, assuming that nginx.service has PrivateTmp= and PrivateNetwork= set, too. Example 5. proxy-to-nginx.socket [Socket] ListenStream=80 [Install] WantedBy=sockets.target Example 6. proxy-to-nginx.service [Unit] Requires=nginx.service After=nginx.service Requires=proxy-to-nginx.socket After=proxy-to-nginx.socket JoinsNamespaceOf=nginx.service [Service] ExecStart=/lib/systemd/systemd-socket-proxyd 127.0.0.1:8080 PrivateTmp=yes PrivateNetwork=yes Example 7. nginx.conf [...] server { listen 8080; [...] Example 8. Enabling the proxy # systemctl enable --now proxy-to-nginx.socket $ curl http://localhost:80/ SEE ALSO
systemd(1), systemd.socket(5), systemd.service(5), systemctl(1), socat(1), nginx(1), curl(1) systemd 237 SYSTEMD-SOCKET-PROXYD(8)
All times are GMT -4. The time now is 10:41 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy