Apply @uberhacker suggestions

parent 8e587f89
...@@ -81,28 +81,30 @@ sudo ln -s `pwd`/crew $CREW_PREFIX/bin ...@@ -81,28 +81,30 @@ sudo ln -s `pwd`/crew $CREW_PREFIX/bin
mkdir $CREW_LIB_PATH/lib && cd $CREW_LIB_PATH/lib mkdir $CREW_LIB_PATH/lib && cd $CREW_LIB_PATH/lib
wget -N -c $URL/lib/package.rb wget -N -c $URL/lib/package.rb
wget -N -c $URL/lib/package_helpers.rb wget -N -c $URL/lib/package_helpers.rb
#create the device.json file
#create or update the device.json file
ruby_version='2.0.0p247'
cd $CREW_CONFIG_PATH cd $CREW_CONFIG_PATH
if [ ! -f device.json ]; then if [ ! -f device.json ]; then
echo "Creating device.json newly..." echo "Creating new device.json..."
echo '{' > device.json echo '{' > device.json
echo ' "architecture": "'$architecture'",' >> device.json echo ' "architecture": "'$architecture'",' >> device.json
echo ' "installed_packages": [' >> device.json echo ' "installed_packages": [' >> device.json
echo ' {' >> device.json echo ' {' >> device.json
echo ' "name": "ruby",' >> device.json echo ' "name": "ruby",' >> device.json
echo ' "version": "2.0.0p247"' >> device.json echo ' "version": "'$ruby_version'"' >> device.json
echo ' }' >> device.json echo ' }' >> device.json
echo ' ]' >> device.json echo ' ]' >> device.json
echo '}' >> device.json echo '}' >> device.json
elif grep '"name": "ruby"' device.json > /dev/null; then elif grep '"name": "ruby"' device.json > /dev/null; then
echo "Updating version number of existing information in device.json..." echo "Updating version number of existing information in device.json..."
sed -i device.json -e '/"name": "ruby"/N;//s/"version": ".*"/"version": "2.0.0p247"/' sed -i device.json -e '/"name": "ruby"/N;//s/"version": ".*"/"version": "'$ruby_version'"/'
else else
echo "Adding new information to device.json..." echo "Adding new information to device.json..."
sed -i device.json -e '/ }$/s/$/,\ sed -i device.json -e '/ }$/s/$/,\
{\ {\
"name": "ruby",\ "name": "ruby",\
"version": "2.0.0p247"\ "version": "'$ruby_version'"\
}/' }/'
fi fi
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment