Skip to content

Commit a4f9483

Browse files
committed
Allow nightlies to be built & signed automatically via a cron job (squashed commits)
This is a combination of 2 commits. ---------- Allow nightlies to be built & signed automatically via a cron job (part 1 - gradle) This commit modifies dSploit's build.gradle to fetch the signing configuration from Bash environment variables. The following environment variables need to be set (i.e: in ~/.bashrc) for the apk signing to work properly. $KEYSTORE_PATH -> the absolute path where the keystore is located $KEYSTORE_PWD -> the keystore passphrase $KEYSTORE_ALIAS -> the keystore alias to use $KEYSTORE_ALIAS_PWD -> the password of the alias defined in the previous variable $NIGHTLIES_OUT_DIR -> the directory where the signed apk should be copied-over once the build has completed successfully (see next commit) Gradle debug tasks don't require those, so we can keep working in Android Studio peacefully. But the `assembleRelease` gradle task will pick those up and sign the apk as defined in the environment variables. See next commit for the crontab and the build script. ---------- Allow nightlies to be built & signed automatically via a cron job (part 2 - bash scripts/cron job) This commit adds 2 scripts: `setup-cronjob.sh` & `nightly-build.sh` + setup-cronjob.sh: This script is a wrapper used to generate a cronjob that will execute `nightly-build.sh` everyday at midnight. The reason we use this script is to get the correct absolute path to the dsploit repository on the machine for the cronjob. Alternatively, you can manually copy `nightly-build.sh` to /etc/cron.daily/ and modify its $DIR variable to point to the dsploit repo. Another way would be to use crontab -e and add the following job: 00 00 * * * /bin/bash /path/to/dsploit/repo/nightly-build.sh + nightly-build.sh: This script is used to build a signed version of the release flavor of dsploit. It will: * build the signed apk * copy the signed apk to the directory the $NIGHTLIES_OUT_DIR environment variable points to, renamed with a timestamp * same as the above, but renamed `latest.apk` The main purpose of this script is to be executed automatically by cron everyday, on a server where the $NIGHTLIES_OUT_DIR points to an accessible location of its web server (i.e: that allows the download of the apk). However, it can be used as a commodity script to manually build signed version of dsploit as well.
1 parent aabcc82 commit a4f9483

File tree

3 files changed

+68
-4
lines changed

3 files changed

+68
-4
lines changed

dSploit/build.gradle

+4-4
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ android {
2323

2424
signingConfigs {
2525
release {
26-
storeFile file("keystore.keystore")
27-
storePassword "YOUR_KEY_PASSWORD"
28-
keyAlias "YOUR_KEY_ALIAS"
29-
keyPassword "YOUR_KEY_PASSWORD"
26+
storeFile = file(System.getenv("KEYSTORE_PATH"))
27+
storePassword = System.getenv("KEYSTORE_PWD")
28+
keyAlias = System.getenv("KEYSTORE_ALIAS")
29+
keyPassword = System.getenv("KEYSTORE_ALIAS_PWD")
3030
}
3131
}
3232

nightly-build.sh

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/bin/bash
2+
3+
# Copyleft (C) 2014 The dSploit Project
4+
#
5+
# Author: Louis Teboul (a.k.a Androguide.fr)
6+
7+
#
8+
# Licensed under the GNU GENERAL PUBLIC LICENSE version 3 'or later'
9+
# The GNU General Public License is a free, copyleft license for software and other kinds of works.
10+
# see the LICENSE file distributed with this work for a full version of the License.
11+
12+
CYAN="\\033[1;36m"
13+
GREEN="\\033[1;32m"
14+
YELLOW="\\E[33;44m"
15+
RED="\\033[1;31m"
16+
RESET="\\e[0m"
17+
DATE=`date +%Y-%m-%d`
18+
LOG_DIR="${DIR}/logs/"
19+
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
20+
21+
if [ ! -d "${LOG_DIR}" ]; then
22+
mkdir -p $LOG_DIR
23+
fi
24+
25+
if [ ! -d "${NIGHTLIES_OUT_DIR}" ]; then
26+
mkdir -p $NIGHTLIES_OUT_DIR
27+
fi
28+
29+
echo -n -e "${CYAN}Building dSploit...${RESET}\n" | tee $LOG_DIR/$DATE.log
30+
./gradlew clean | tee $LOG_DIR/$DATE.log
31+
./gradlew assembleRelease | tee $LOG_DIR/$DATE.log
32+
33+
echo -n -e "${GREEN}Copying signed apk to output directory${RESET} ('NIGHTLIES_OUT_DIR' environment variable)\n" | tee $LOG_DIR/$DATE.log
34+
cp $DIR/dSploit/build/apk/dSploit-release.apk $NIGHTLIES_OUT_DIR/dSploit-$DATE-nightly.apk | tee $LOG_DIR/$DATE.log
35+
36+
echo -n -e "${GREEN}Done.${RESET}\n\n" | tee $LOG_DIR/$DATE.log
37+

setup-cronjob.sh

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/bin/bash
2+
3+
# Copyleft (C) 2014 The dSploit Project
4+
#
5+
# Author: Louis Teboul (a.k.a Androguide.fr)
6+
7+
#
8+
# Licensed under the GNU GENERAL PUBLIC LICENSE version 3 'or later'
9+
# The GNU General Public License is a free, copyleft license for software and other kinds of works.
10+
# see the LICENSE file distributed with this work for a full version of the License.
11+
12+
CYAN="\\033[1;36m"
13+
GREEN="\\033[1;32m"
14+
RESET="\\e[0m"
15+
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
16+
17+
if [ -f "${DIR}/cronjob.txt" ]; then
18+
rm -f $DIR/cronjob.txt
19+
fi
20+
21+
echo -n -e "${CYAN}Generating cronjob file...${RESET}"
22+
echo "00 00 * * * /bin/bash ${DIR}/nightly-build.sh" > $DIR/cronjob.txt
23+
24+
echo -n -e "${CYAN}Adding job to cron...${RESET}"
25+
crontab cronjob.txt
26+
27+
echo -n -e "${GREEN}Done.${RESET}"

0 commit comments

Comments
 (0)