Skip to content

Instantly share code, notes, and snippets.

@janimo
Last active August 29, 2015 14:01
Show Gist options
  • Save janimo/0d559c648ab8874b8fa9 to your computer and use it in GitHub Desktop.
Save janimo/0d559c648ab8874b8fa9 to your computer and use it in GitHub Desktop.
Checks whether a given kernel config file has the options required to run Ubuntu Touch
#!/bin/bash
FILE=$1
[ -f "$FILE" ] || {
echo "Provide a config file as argument"
exit
}
CONFIGS_ON="
CONFIG_SYSVIPC
CONFIG_NAMESPACES
CONFIG_UTS_NS
CONFIG_IPC_NS
CONFIG_USER_NS
CONFIG_PID_NS
CONFIG_NET_NS
CONFIG_DEVTMPFS
CONFIG_DEVTMPFS_MOUNT
CONFIG_DEVPTS_MULTIPLE_INSTANCES
CONFIG_FSNOTIFY
CONFIG_DNOTIFY
CONFIG_INOTIFY_USER
CONFIG_FANOTIFY
CONFIG_FANOTIFY_ACCESS_PERMISSIONS
CONFIG_SWAP
CONFIG_VT
CONFIG_VT_CONSOLE
CONFIG_SECURITY
CONFIG_SECURITYFS
CONFIG_DEFAULT_SECURITY_APPARMOR
CONFIG_SECURITY_APPARMOR
"
CONFIGS_OFF="
CONFIG_ANDROID_PARANOID_NETWORK
CONFIG_DEFAULT_SECURITY_DAC
"
CONFIGS_EQ="
CONFIG_DEFAULT_SECURITY=\"apparmor\"
"
ered() {
echo -e "\033[31m" $@
}
egreen() {
echo -e "\033[32m" $@
}
echo -e "\n\nChecking config file for Ubuntu Touch specific config options.\n\n"
errors=0
for c in $CONFIGS_ON $CONFIGS_OFF;do
cnt=`grep -w -c $c $FILE`
if [ $cnt -gt 1 ];then
ered "$c appears more than once in the config file, fix this"
errors=$((errors+1))
fi
if [ $cnt -eq 0 ];then
ered "$c is neither enabled nor disabled in the config file"
errors=$((errors+1))
fi
done
for c in $CONFIGS_ON;do
if grep "$c=y" $FILE >/dev/null;then
egreen "$c is set"
else
ered "$c is not set, set it"
errors=$((errors+1))
fi
done
for c in $CONFIGS_EQ;do
if grep "$c" $FILE >/dev/null;then
egreen "$c is set"
else
ered "$c is not set, set it"
errors=$((errors+1))
fi
done
for c in $CONFIGS_OFF;do
if grep "$c=y" $FILE >/dev/null;then
ered "$c is set, unset it"
errors=$((errors+1))
else
egreen "$c is not set"
fi
done
echo -e "\n\nConfig file checked, found $errors errors.\n\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment