Solaris NodeJS zone install and configuration

First, lets Compile NodJS from source, get the source from the NodeJS website.
Something like the below should work to compile.

env CC=gcc ./configure --prefix=/opt/node-v6.2.2
# for 8 cpu's
gmake -j 8
gmake install

Next, lets modify the zone properties and distribute the compiled bundle to all the Solaris zones.
Something like the below will work on 9 zones (from a – i).

perl -p -i -e 's,root::::type=role,root::::type=normal,' /etc/user_attr
perl -p -i -e 's,PermitRootLogin no,PermitRootLogin yes,' /etc/ssh/sshd_config
svcadm restart ssh

for i in {a..i};do scp Downloads/node-v6.2.2-sunos-x64.tar.gz njs1$i:/tmp/;done
for i in {a..i};do ssh njs1$i "groupadd nodejs";done
for i in {a..i};do ssh njs1$i 'useradd -d /export/home/nodejs -g nodejs -m -s /bin/bash -c "NodeJS App" nodejs' ;done

for i in {a..i};do ssh njs1$i 'zfs create -o mountpoint=/opt/node rpool/node' ;done

for i in {a..i};do echo $i; ssh njs1$i 'cd /opt/node;tar zxf /tmp/node-v6.2.2-sunos-x64.tar.gz' ;done

for i in {a..i};do ssh njs1$i 'ln -s /root/.bashrc /root/.bash_profile';done

for i in {a..i};do ssh njs1$i 'cd /opt/node; ln -s node-v6.2.2-sunos-x64 node';done 
for i in {a..i};do ssh njs1$i 'chown -R nodejs:nodejs /opt/node';done

# Install Nginx from OpenCSW (needs to pass a proxy to download)
for i in {a..i};do ssh -R njs1$i 'export http_proxy=;echo y|pkgadd -d; /opt/csw/bin/pkgutil -i nginx';done

for i in {a..i};do ssh njs1$i 'echo "export PATH=/opt/node/node/bin:$PATH" >> /export/home/nodejs/.profile';done

# Set a password 
passwd nodejs

# Create Nginx authorization for SMF
echo "nodejs::::auths=solaris.smf.manage.nginx" >>/etc/user_attr
echo "solaris.smf.manage.nginx:::enable, disable and refresh nginx::" >> /etc/security/auth_attr.d/local-entries 

Finally, add to smf solaris.smf.manage.nginx as allow and re-import the smf service.

for i in {a..i};do scp /tmp/foo njs1$i:/tmp/smf.xml;done
for i in {b..i};do ssh njs1$i 'svccfg delete svc:/network/cswnginx; svccfg import /tmp/foo';done

Add access to nginx conf file

for i in {a..i};do ssh njs1$i 'chown nodejs /etc/opt/csw/nginx/nginx.conf' ;done

An example of nginx SMF xml with the authorization added.


0 0 votes
Article Rating
Notify of
Inline Feedbacks
View all comments
Would love your thoughts, please comment.x
%d bloggers like this: