#!/bin/bash

echo "This is test script received args : $*"

function check_if_fakeroot(){
  echo -n "AM i running under fakeroot?"
  [ -z "${FAKEROOTKEY}"] && echo "no" && exit 1;
  echo yes, FAKEROOTKEY:$FAKEROOTKEY
}

function copy_new_app(){
  cp ./factorial.bin $1/usr/bin
  echo -n "./factorial.bin &" >> $1/etc/rc.d/rc.local
  echo " " >> $1/etc/rc.d/rc.local
}

function main(){
  check_if_fakeroot
  copy_new_app $1
  exit 0;
}

main $*
