juci-sysupgrade: fix javascript errors that prevented network upgrade refs #15420
[juci.git] / scripts / ubuntu-bootstrap.sh
1 #!/bin/bash
2
3 apt_packages="npm nodejs yui-compressor"
4 needed=""
5
6 for pkg in $apt_packages; do
7         if ! dpkg -s $pkg >/dev/null 2>/dev/null; then
8                 needed="$needed $pkg"
9         fi
10 done
11
12 if [ -n "$needed" ]; then
13         echo "Need to install dpkg packages [$needed]"
14         read -p "Do you approve installation of these packages (y/n): " ans
15         if [ "$ans" == "y" ]; then
16                 sudo apt-get install $needed
17         else
18                 echo "can't continue. aborting!"
19                 exit 1
20         fi
21
22         #less = compile less to css
23         #mocha = javascript test framework
24         #npm = NPM
25         #uglify-js = compressing javascript files
26         npm_package="less mocha npm uglify-js"
27         needed=""
28
29         # Filter out already installed packages 
30         for pkg in $npm_package; do
31                 if ! npm list -g $pkg >/dev/null 2>/dev/null; then
32                         needed="$needed $pkg"
33                 fi
34         done
35
36         # install needed packages
37         if [ -n "$needed" ]; then
38                 echo "Need to install npm package $needed"
39                 for pkg in $needed; do
40                         sudo npm install -g $pkg
41                 done
42         fi
43
44         sudo chown -R $USER:$USER /home/$USER/.npm/
45 else
46         echo "Youre system is up to date"
47 fi