commit bc4e59dbff9eef8286ce8f1149cb1515d6333fcf Author: pan <1029559041@qq.com> Date: Wed Jun 16 16:41:51 2021 +0800 'init' diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0bcc7c4 --- /dev/null +++ b/.gitignore @@ -0,0 +1,75 @@ +# Created by .ignore support plugin (hsz.mobi) +### JetBrains template +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf + +# Generated files +.idea/**/contentModel.xml + +# Sensitive or high-churn files +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml + +# Gradle +.idea/**/gradle.xml +.idea/**/libraries + +# Gradle and Maven with auto-import +# When using Gradle or Maven with auto-import, you should exclude module files, +# since they will be recreated, and may cause churn. Uncomment if using +# auto-import. +# .idea/artifacts +# .idea/compiler.xml +# .idea/modules.xml +# .idea/*.iml +# .idea/modules +# *.iml +# *.ipr + +# CMake +cmake-build-*/ + +# Mongo Explorer plugin +.idea/**/mongoSettings.xml + +# File-based project format +*.iws + +# IntelliJ +out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +# Editor-based Rest Client +.idea/httpRequests + +# Android studio 3.1+ serialized cache file +.idea/caches/build_file_checksums.ser + +.idea +time.log diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..411fd2a --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "grub\\Grub"] + path = grub\\Grub + url = https://github.com/luffy9412/Grub.git diff --git a/README.md b/README.md new file mode 100644 index 0000000..9d9eed2 --- /dev/null +++ b/README.md @@ -0,0 +1,6 @@ +1. [git重写提交历史](git) + 执行[time.sh](git/time.sh)格式化输出git提交历史日期和时间戳, + 编辑[rename.sh](git/rename.sh)需要修改的提交历史时间戳条件,运行即可修改 + 历史记录并提交到远程仓库。 +2. [UEFI启动光盘镜像制作](grub) + 支持UEFI启动的GRUB2 ISO光盘镜像的制作 \ No newline at end of file diff --git a/git/rename.sh b/git/rename.sh new file mode 100644 index 0000000..c2b29ac --- /dev/null +++ b/git/rename.sh @@ -0,0 +1,14 @@ +#重写提交历史 +git filter-branch -f --commit-filter ' + #重写提交时间等于指定时间戳的历史 + if [ "$GIT_COMMITTER_DATE" = "@1582736444 +0800" ]; + then + GIT_COMMITTER_NAME="saber666"; + GIT_AUTHOR_NAME="$GIT_COMMITTER_NAME"; + GIT_COMMITTER_EMAIL="saber@qq.com"; + GIT_AUTHOR_EMAIL="$GIT_COMMITTER_EMAIL" + git commit-tree "$@"; + else + git commit-tree "$@"; + fi' HEAD +git push -f diff --git a/git/time.sh b/git/time.sh new file mode 100644 index 0000000..ddf232b --- /dev/null +++ b/git/time.sh @@ -0,0 +1,2 @@ +#格式化输出git提交历史日期 +git log --pretty=%cd|awk '{info=$0;gsub(/ /,"",info);cmd="echo 日期:`date -j -f ""%c%z"" "info" ""+%Y/%m/%d,%I:%M%p""`,时间戳:`date -j -f ""%c%z"" "info" +%s`";print system(cmd)}'|awk 'NR%2==0{next}{line=$0;gsub(/PM/," 下午",line);gsub(/AM/," 上午",line);print line}' diff --git a/grub/Grub b/grub/Grub new file mode 160000 index 0000000..ea1cea3 --- /dev/null +++ b/grub/Grub @@ -0,0 +1 @@ +Subproject commit ea1cea39643490c55a2960ad6975a152cc6f522a diff --git a/grub/createhda b/grub/createhda new file mode 100644 index 0000000..368549b --- /dev/null +++ b/grub/createhda @@ -0,0 +1,3 @@ +#!/bin/bash + +qemu-img create -f qcow2 hda.img 10m diff --git a/grub/createiso b/grub/createiso new file mode 100644 index 0000000..c396956 --- /dev/null +++ b/grub/createiso @@ -0,0 +1,75 @@ +#!/bin/bash +#生成grub iso +#根据论坛http://wuyou.net/forum.php?mod=viewthread&tid=386651 +#封装的命令,感谢rkr077大佬分享 + + +if [ $# -ne 3 ];then + echo 参数校验失败 + echo '命令用法:' + echo './createiso grub目录 输出iso文件名 回环设备' + echo '例如:./createiso grub test.iso /dev/loop3' + exit +fi + + +#回环设备 +loop=$3 + +if [ `losetup -a|grep $loop|wc -l` -gt 0 ];then + echo 回环设备$loop已被占用 +else +echo '1.生成GRUB2的内核文件(core.img)' +#先使用bootice的GRUB4DOS编辑器编写grub.cfg文件(以UTF-8编码保存),包含以下内容: +config_name=grub.cfg +grub_path=/boot/grub +core_img=core.img +iso_dir=iso +efi_dir=efi +efi_path=$efi_dir/boot +efi_img=cdefi.img + + +mnt_path=/mnt/image +grub2cd_img=grub2cd.img +bootx64=bootx64.efi +bootia32=bootia32.efi +cat << EOF > $config_name +search.file $grub_path/$config_name root +set prefix=$grub_path +normal +EOF +#然后执行以下命令: +#Legacy启动 +grub-mkimage -c $config_name -p $grub_path -o $core_img -O i386-pc iso9660 udf fat exfat ntfs ext2 part_msdos part_gpt search disk biosdisk normal halt reboot +#64位UEFI启动 +grub-mkimage -c $config_name -p $grub_path -o $bootx64 -O x86_64-efi iso9660 udf fat exfat ntfs ext2 part_msdos part_gpt search disk normal halt reboot +#32位UEFI启动 +grub-mkimage -c $config_name -p $grub_path -o $bootia32 -O i386-efi iso9660 udf fat exfat ntfs ext2 part_msdos part_gpt search disk normal halt reboot +#将GRUB2安装目录下的i386-pc\cdboot.img文件复制到当前目录下,并用copy命令将cdboot.img和$core_img文件合并为$grub2cd_img +cat /usr/lib/grub/i386-pc/cdboot.img $core_img >$grub2cd_img +#2.生成EFI启动镜像 +echo '2.生成EFI启动镜像' +mkdir -p $efi_path +cp $bootx64 $bootia32 $efi_path +#采用dd命令生成的镜像文件 +dd if=/dev/zero of=$efi_img bs=1 count=1M +mkfs -t vfat $efi_img +losetup $loop $efi_img #映射loop设备 +mount $loop $mnt_path #挂载loop设备 +cp -r $efi_path $mnt_path +losetup -d $loop #解除loop映射 +umount $mnt_path #卸载loop设备 +#3.用genisoimage命令生成可启动iso文件 +echo '3.用genisoimage命令生成可启动iso文件' +# #在iso文件夹下面新建boot\grub文件夹,将输入参数指定的grub目录拷贝到$iso_dir/$grub_path下 +mkdir -p $iso_dir/$grub_path +cp -r $1/* $iso_dir/$grub_path +# #将grub2cd.img和cdefi.img复制到iso文件夹下面。 +cp $efi_img $grub2cd_img $iso_dir +# #执行以下命令生成iso文件 +genisoimage -J -l -allow-lowercase -R -V GRUB2 -joliet-long -no-emul-boot -boot-load-size 4 -boot-info-table -b $grub2cd_img -eltorito-alt-boot -b $efi_img -no-emul-boot -o $2 $iso_dir +rm -rf $core_img $bootx64 $bootia32 $config_name $grub2cd_img $efi_img $iso_dir $efi_dir +fi + + diff --git a/grub/runiso b/grub/runiso new file mode 100644 index 0000000..e447a86 --- /dev/null +++ b/grub/runiso @@ -0,0 +1,2 @@ +#!/bin/bash +qemu-system-x86_64 -hda hda.img -boot d -cdrom test.iso