Skip to content

Commit

Permalink
Prepare release for install
Browse files Browse the repository at this point in the history
  • Loading branch information
maditnerd committed Jan 28, 2016
1 parent 55819b9 commit a312574
Showing 1 changed file with 148 additions and 99 deletions.
247 changes: 148 additions & 99 deletions install
@@ -1,104 +1,153 @@
#!/bin/bash

if [ $(id -u) -eq 0 ];then
echo "--> Install script v1.1"

echo "Updating package"
debconf-apt-progress -- apt-get -q -y update
debconf-apt-progress -- apt-get -q -y upgrade
debconf-apt-progress -- apt-get install -q -y git
debconf-apt-progress -- apt-get install -q -y python-pip

#If boot was not copied manually
if [ ! -d /boot/piget ];then
rm -rf /tmp/bootstrap
echo "Copy /boot/piget"
git clone https://github.com/pigetnet/bootstrap /tmp/bootstrap
mv /tmp/bootstrap/piget /boot/piget
fi

#Generating piget directory
if [ ! -d /opt/piget ];then
mkdir /opt/piget
fi

if [ ! -d /opt/user ];then
mkdir /opt/user
fi

if [ ! -d /opt/user/scripts ];then
mkdir /opt/user/scripts
fi

#User data directory

if [ ! -d /opt/user/config ];then
mkdir /opt/user/config
fi

if [ ! -d /opt/user/data ];then
mkdir /opt/user/data
fi

if [ ! -d /opt/user/state ];then
mkdir /opt/user/state
fi

#We remove core functions if previously installed
rm -rf /opt/piget/core

#Cloning core scripts repository
git clone https://github.com/pigetnet/core /opt/piget/core

#Create link
if [ -L /net ];then
rm /net
fi

if [ -L /pi ];then
rm /pi
fi

if [ -L /show ];then
rm /show
fi

if [ -L /string ];then
rm /string
fi

if [ -L /system ];then
rm /system
fi

if [ -L /do ];then
rm /do
fi

if [ -L /user ];then
rm /user
fi

ln -sv /opt/piget/core/net /net
ln -sv /opt/piget/core/pi /pi
ln -sv /opt/piget/core/show /show
ln -sv /opt/piget/core/string /string
ln -sv /opt/piget/core/system /system
ln -sv /opt/piget/ /do
ln -sv /opt/user/ /user

/system/modifyBashStartup core
pip install tzupdate
tzupdate


/show/description "PIGET WAS SUCCESFULLY INSTALLED"

if [ -f /boot/piget/scripts/postinstall.sh ]
then
/show/description "POST INSTALL SCRIPT FOUNDED"
chmod +x /boot/piget/scripts/postinstall.sh
/boot/piget/scripts/postinstall.sh
fi

ERR="\033[1;31m"
NORMAL="\033[0;39m"
INFO="\033[1;34m"
WARN="\033[1;33m"
OK="\033[1;32m"


updatePi(){
echo "Updating package"
debconf-apt-progress -- apt-get -q -y update
debconf-apt-progress -- apt-get -q -y upgrade
debconf-apt-progress -- apt-get install -q -y git
debconf-apt-progress -- apt-get install -q -y python-pip
}

pigetLogo(){

echo -ne $OK

cat<<EOF
██████╗ ██╗ ██████╗ ███████╗████████╗
██╔══██╗██║██╔════╝ ██╔════╝╚══██╔══╝
██████╔╝██║██║ ███╗█████╗ ██║
██╔═══╝ ██║██║ ██║██╔══╝ ██║
██║ ██║╚██████╔╝███████╗ ██║
╚═╝ ╚═╝ ╚═════╝ ╚══════╝ ╚═╝
EOF

echo -ne $NORMAL
}


copyBoot(){
#If boot was not copied manually
if [ ! -d /boot/piget ];then
rm -rf /tmp/bootstrap
echo "Copy /boot/piget"
git clone https://github.com/pigetnet/bootstrap /tmp/bootstrap
mv /tmp/bootstrap/piget /boot/piget
fi
}

generateDir(){
# Create piget directory
if [ ! -d /opt/piget ];then
mkdir /opt/piget
fi

# Create user dirs
if [ ! -d /opt/user ];then
mkdir /opt/user
fi

# Create users scripts dir
if [ ! -d /opt/user/scripts ];then
mkdir /opt/user/scripts
fi

# Create user config
if [ ! -d /opt/user/config ];then
mkdir /opt/user/config
fi

# Create user data
if [ ! -d /opt/user/data ];then
mkdir /opt/user/data
fi

# Create user state
if [ ! -d /opt/user/state ];then
mkdir /opt/user/state
fi
}

generateCore(){
if [ -d /opt/piget/core ];then
#We remove core functions if previously installed
rm -rf /opt/piget/core
fi
#Cloning core scripts repository
git clone https://github.com/pigetnet/core /opt/piget/core
}

createSymLink(){
#Remove previously created links
if [ -L /net ];then
rm /net
fi

if [ -L /pi ];then
rm /pi
fi

if [ -L /show ];then
rm /show
fi

if [ -L /string ];then
rm /string
fi

if [ -L /system ];then
rm /system
fi

if [ -L /do ];then
rm /do
fi

if [ -L /user ];then
rm /user
fi

#Generate links
ln -sv /opt/piget/core/net /net
ln -sv /opt/piget/core/pi /pi
ln -sv /opt/piget/core/show /show
ln -sv /opt/piget/core/string /string
ln -sv /opt/piget/core/system /system
ln -sv /opt/piget/ /do
ln -sv /opt/user/ /user
}

editBashrc(){
/system/modifyBashStartup core
}

configureTimeZone(){
pip install tzupdate
tzupdate
}

postInstallScript(){
if [ -f /boot/piget/scripts/postinstall.sh ];then
/show/description "POST INSTALL SCRIPT FOUNDED"
chmod +x /boot/piget/scripts/postinstall.sh
/boot/piget/scripts/postinstall.sh
fi
}

pigetLogo





else
echo "You must be root to install piget"
echo "Try: curl -L piget.madnerd.org|sudo bash"
Expand Down

0 comments on commit a312574

Please sign in to comment.